Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional certificate utility methods #67

Open
serac opened this issue Mar 14, 2024 · 1 comment
Open

Additional certificate utility methods #67

serac opened this issue Mar 14, 2024 · 1 comment
Assignees

Comments

@serac
Copy link
Member

serac commented Mar 14, 2024

Add the following useful methods to CertUtil:

  1. encodeCert - produce the PEM-encoding given an X509Certificate object
  2. subjectDN - produce a string version of the subject of the given X509Certificate object
  3. generateCert - Produce a self-signed X509Certificate object given a key pair and validity period as a Duration

For (2), consider flags or overloaded variants that optionally produce output containing spaces; for example:

System.out.println(selfSignedCert.getSubjectX500Principal().toString());
CN=middleware-test, OU=Middleware, O=Virginia Polytechnic Institute and State University, L=Blacksburg, ST=Virginia, DC=vt, DC=edu, C=US
System.out.println(selfSignedCert.getSubjectX500Principal().getName());
CN=middleware-test,OU=Middleware,O=Virginia Polytechnic Institute and State University,L=Blacksburg,ST=Virginia,DC=vt,DC=edu,C=US

Comparing DNs by string representation is fraught with peril, but providing both outputs could be helpful for simple cases.

For(3) the method should support both RSA and EC keys.

@haripri-vt haripri-vt self-assigned this Mar 14, 2024
@haripri-vt
Copy link
Contributor

#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants