How to fix the error "Topic class type is invalid."

I use java to encode the CA module to create and sign a certificate. When I run my code, the error "The theme class type is invalid." but in the destination folder I can get two files: rooca.crt and rootca.pfx . The certificate contains the information that I installed. The code may be correct, but I still want to fix the error.

Exception Details:

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 image description here enter the code here

+5
source share
2 answers

I had a similar problem. This code works well with Java 1.6 and does not work with this exception while working on Java 1.8.

I can fix this problem by running the following solution .

In fact, in Java 1.8, it seems like you no longer need to encapsulate the X500Name in a CertificateSubjectName or CertificateIssuerName. You can save the X500Name object directly to the X509CertInfo instance.

+8
source

Change this "info.set" (X509CertInfo.SUBJECT, new CertificateSubjectName (subject)); To info.set (X509CertInfo.SUBJECT, theme); it works for me

0
source

All Articles