|
25 | 25 | import java.io.IOException; |
26 | 26 | import java.io.InputStream; |
27 | 27 | import java.io.ByteArrayInputStream; |
| 28 | +import java.nio.charset.Charset; |
28 | 29 | import java.math.BigInteger; |
29 | 30 | import java.text.ParseException; |
30 | 31 | import java.text.SimpleDateFormat; |
@@ -62,7 +63,7 @@ public class WolfSSLCertificate { |
62 | 63 | static native byte[] X509_get_signature(long x509); |
63 | 64 | static native String X509_get_signature_type(long x509); |
64 | 65 | static native String X509_get_signature_OID(long x509); |
65 | | - static native String X509_print(long x509); |
| 66 | + static native byte[] X509_print(long x509); |
66 | 67 | static native int X509_get_isCA(long x509); |
67 | 68 | static native String X509_get_subject_name(long x509); |
68 | 69 | static native String X509_get_issuer_name(long x509); |
@@ -600,7 +601,20 @@ public X509Certificate getX509Certificate() |
600 | 601 |
|
601 | 602 | @Override |
602 | 603 | public String toString() { |
603 | | - return X509_print(this.x509Ptr); |
| 604 | + |
| 605 | + byte[] x509Text; |
| 606 | + |
| 607 | + if (this.active == false) { |
| 608 | + return super.toString(); |
| 609 | + } |
| 610 | + |
| 611 | + x509Text = X509_print(this.x509Ptr); |
| 612 | + if (x509Text != null) { |
| 613 | + /* let Java do the modified UTF-8 conversion */ |
| 614 | + return new String(x509Text, Charset.forName("UTF-8")); |
| 615 | + } |
| 616 | + |
| 617 | + return super.toString(); |
604 | 618 | } |
605 | 619 |
|
606 | 620 | /** |
|
0 commit comments