0

I am using something similar to this code. How can I add set the Subject Alternative Names in my certificate programmatically using sun.security?

user1156544
  • 1,725
  • 2
  • 25
  • 51

1 Answers1

3

OK, it was a bit tricky to trace several sources but here it is the clue (in case it can help anyone in future as I have been helped other times):

CertificateExtensions ext = new CertificateExtensions();

ext.set(SubjectAlternativeNameExtension.NAME, new SubjectAlternativeNameExtension(....*));

// * a `GeneralNames` object including a `GeneralName` object including (for example) an `IPAddressName` object.

And then pass the object ext to the constructor of the certificate.

user1156544
  • 1,725
  • 2
  • 25
  • 51
  • 1
    That's correct. You figured before I could comment. Subjectalternativename is defined as extension. So you should create a new object of type CertificateExtension. – Kaushal Kumar Panday Jul 05 '17 at 15:33