2222import java .util .concurrent .TimeUnit ;
2323import java .util .regex .Matcher ;
2424import java .util .regex .Pattern ;
25+ import java .net .InetAddress ;
2526
2627import static java .lang .String .format ;
2728import static java .time .Duration .ZERO ;
@@ -134,7 +135,6 @@ public CertificateRequest generateRequest(ZoneConfiguration config, CertificateR
134135 if ("0" .equals (config .customAttributeValues ().get (tppAttributeManualCSR ))) {
135136 throw new VCertException ("Unable to request certificate with user provided CSR when zone configuration is 'Manual Csr' = 0" );
136137 }
137- request .generatePrivateKey ();
138138 if (Is .blank (request .csr ())) {
139139 throw new VCertException ("CSR was supposed to be provided by user, but it's empty" );
140140 }
@@ -164,11 +164,18 @@ private CertificateRequestsPayload prepareRequest(CertificateRequest request, St
164164 CertificateRequestsPayload payload ;
165165 switch (request .csrOrigin ()) {
166166 case LocalGeneratedCSR :
167+ payload = new CertificateRequestsPayload ()
168+ .policyDN (getPolicyDN (zone ))
169+ .pkcs10 (new String (request .csr ()))
170+ .objectName (request .friendlyName ())
171+ .disableAutomaticRenewal (true );
172+ break ;
167173 case UserProvidedCSR :
168174 payload = new CertificateRequestsPayload ()
169175 .policyDN (getPolicyDN (zone ))
170176 .pkcs10 (new String (request .csr ()))
171177 .objectName (request .friendlyName ())
178+ .subjectAltNames (wrapAltNames (request ))
172179 .disableAutomaticRenewal (true );
173180 break ;
174181 case ServiceGeneratedCSR :
@@ -191,7 +198,7 @@ private CertificateRequestsPayload prepareRequest(CertificateRequest request, St
191198 }
192199 case ECDSA : {
193200 payload .keyAlgorithm ("ECC" );
194- payload .ellipticCurve (request .keyCurve ().name ());
201+ payload .ellipticCurve (request .keyCurve ().value ());
195202 break ;
196203 }
197204 }
@@ -212,7 +219,7 @@ private List<SANItem> toSanItems(Collection<?> collection, int type) {
212219 .orElse (Collections .emptyList ())
213220 .stream ()
214221 .filter (Objects ::nonNull )
215- .map (entry -> new SANItem ().type (type ).name (entry . toString ()))
222+ .map (entry -> new SANItem ().type (type ).name ( type == 7 ? (( InetAddress ) entry ). getHostAddress () : entry . toString ()) )
216223 .collect (toList ());
217224 }
218225
@@ -224,7 +231,7 @@ public PEMCollection retrieveCertificate(CertificateRequest request) throws VCer
224231 if (isNotBlank (request .pickupId ()) && isNotBlank (request .thumbprint ())) {
225232 Tpp .CertificateSearchResponse searchResult = searchCertificatesByFingerprint (request .thumbprint ());
226233 if (searchResult .certificates ().size () == 0 ) {
227- throw new VCertException (format ("No certifiate found using fingerprint %s" , request .thumbprint ()));
234+ throw new VCertException (format ("No certificate found using fingerprint %s" , request .thumbprint ()));
228235 }
229236 if (searchResult .certificates ().size () > 1 ) {
230237 throw new VCertException (format ("Error: more than one CertificateRequestId was found with the same thumbprint %s" , request .thumbprint ()));
@@ -418,6 +425,7 @@ static class CertificateRequestsPayload {
418425 private String city ;
419426 private String state ;
420427 private String country ;
428+ @ SerializedName ("SubjectAltNames" )
421429 private Collection <SANItem > subjectAltNames ;
422430 private String contact ;
423431 @ SerializedName ("CASpecificAttributes" )
0 commit comments