I am looking for a utility class that can generate random certificate strings for testing purposes. Any idea if there is one already implemented?
I am looking for a utility class that can generate random certificate strings for
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The built-in Java X500 libraries are geared more towards using certificates than generating and parsing certificates. You might find a way to do what you want, but it would almost certainly be messy and in a protected API (
sun.security.*).I suggest you include the Bouncy Castle library (Apache License). It has a class called
X509V3CertificateGeneratorthat you can use to set the fields of a certificate (issuer, subject, expiry date, etc).You should then be able to get the PEM string from it using the
PEMWriterclass.