chore: Fixup test failures introduced by cert import
This commit is contained in:
parent
4b863fec42
commit
f8e9158a76
3 changed files with 24 additions and 8 deletions
|
@ -29,7 +29,14 @@ public class Certificate {
|
|||
|
||||
private String trustingAuthority;
|
||||
|
||||
@Min(1)
|
||||
/**
|
||||
* <ul>
|
||||
* <li>-1 = no requested key length is known (might happen with imported certificates)</li>
|
||||
* <li>0 = no key is available for this certificate (might happen with trusted third party certificates)</li>
|
||||
* <li>> 1 = The key length in bits used for the private key of this certificate</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Min(-1)
|
||||
private int requestedKeyLength;
|
||||
|
||||
private OffsetDateTime notBefore;
|
||||
|
|
|
@ -32,4 +32,8 @@ public record X509CertificateInfo(
|
|||
}
|
||||
return Collections.unmodifiableList(extensions);
|
||||
}
|
||||
|
||||
public boolean hasExtensions() {
|
||||
return extensions != null && !extensions.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,9 @@ public class CertificateCreationService {
|
|||
)
|
||||
);
|
||||
certificate.setSubjectCommonName(info.subject().getCommonName());
|
||||
certificate.setTrustingAuthority(info.issuer().getCommonName());
|
||||
if (info.issuer() != null) {
|
||||
certificate.setTrustingAuthority(info.issuer().getCommonName());
|
||||
}
|
||||
certificate.setRequestedKeyLength(-1);
|
||||
certificate.setNotBefore(info.notBefore());
|
||||
certificate.setNotAfter(info.notAfter());
|
||||
|
@ -100,12 +102,14 @@ public class CertificateCreationService {
|
|||
certificate.setSubjectState(subjectInfo.getState());
|
||||
certificate.setSubjectLocality(subjectInfo.getLocality());
|
||||
|
||||
final CertificateInfoExtension extension = info.extensions().getFirst();
|
||||
if (extension != null) {
|
||||
final CertificateExtension certificateExtension = new CertificateExtension();
|
||||
certificateExtension.setIdentifier("alternativeNames");
|
||||
certificateExtension.setValue(String.join(",", extension.getAlternativeDnsNames()));
|
||||
certificate.setCertificateExtension(List.of(certificateExtension));
|
||||
if (info.hasExtensions()) {
|
||||
final CertificateInfoExtension extension = info.extensions().getFirst();
|
||||
if (extension != null) {
|
||||
final CertificateExtension certificateExtension = new CertificateExtension();
|
||||
certificateExtension.setIdentifier("alternativeNames");
|
||||
certificateExtension.setValue(String.join(",", extension.getAlternativeDnsNames()));
|
||||
certificate.setCertificateExtension(List.of(certificateExtension));
|
||||
}
|
||||
}
|
||||
return certificate;
|
||||
}
|
||||
|
@ -119,6 +123,7 @@ public class CertificateCreationService {
|
|||
try {
|
||||
String fingerprint = openSSLService.getCertificateFingerprint(certificate);
|
||||
Certificate entity = createEntityFromInfo(openSSLService.getCertificateInfo(certificate));
|
||||
entity.setRequestedKeyLength(-1);
|
||||
entity.setFingerprint(fingerprint);
|
||||
entity.setCert(Files.readAllBytes(certificate));
|
||||
if (keyFile != null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue