I use java to code a CA module to create and sign the certificate. When I run my code, the error "Subject class type invalid." appeared, but in the destination folder I can get the two files: rooca.crt and rootca.pfx. The certificate contains the information I set. Maybe the code is result is right, but I still want to fix the error.
The details of the exception:
java.security.cert.CertificateException: Subject class type invalid.
at sun.security.x509.X509CertInfo.setSubject(Unknown Source)
at sun.security.x509.X509CertInfo.set(Unknown Source)
at com.koal.Test.createIssueCert(Test.java:124)
at com.koal.Test.main(Test.java:353)
Part of my code: enter code here
I faced a similar problem. This code is working well with Java 1.6 and fail with this exception while running on Java 1.8.
I can fix this issue by implementing the following solution.
In fact, in Java 1.8, it seems that you do not have to encapsulate anymore the X500Name into CertificateSubjectName or CertificateIssuerName. You can store the X500Name object directly in the X509CertInfo instance.
Change this "info.set(X509CertInfo.SUBJECT, new CertificateSubjectName(subject));" To info.set(X509CertInfo.SUBJECT, subject); it work for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With