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;
|
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 int requestedKeyLength;
|
||||||
|
|
||||||
private OffsetDateTime notBefore;
|
private OffsetDateTime notBefore;
|
||||||
|
|
|
@ -32,4 +32,8 @@ public record X509CertificateInfo(
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(extensions);
|
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.setSubjectCommonName(info.subject().getCommonName());
|
||||||
|
if (info.issuer() != null) {
|
||||||
certificate.setTrustingAuthority(info.issuer().getCommonName());
|
certificate.setTrustingAuthority(info.issuer().getCommonName());
|
||||||
|
}
|
||||||
certificate.setRequestedKeyLength(-1);
|
certificate.setRequestedKeyLength(-1);
|
||||||
certificate.setNotBefore(info.notBefore());
|
certificate.setNotBefore(info.notBefore());
|
||||||
certificate.setNotAfter(info.notAfter());
|
certificate.setNotAfter(info.notAfter());
|
||||||
|
@ -100,6 +102,7 @@ public class CertificateCreationService {
|
||||||
certificate.setSubjectState(subjectInfo.getState());
|
certificate.setSubjectState(subjectInfo.getState());
|
||||||
certificate.setSubjectLocality(subjectInfo.getLocality());
|
certificate.setSubjectLocality(subjectInfo.getLocality());
|
||||||
|
|
||||||
|
if (info.hasExtensions()) {
|
||||||
final CertificateInfoExtension extension = info.extensions().getFirst();
|
final CertificateInfoExtension extension = info.extensions().getFirst();
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
final CertificateExtension certificateExtension = new CertificateExtension();
|
final CertificateExtension certificateExtension = new CertificateExtension();
|
||||||
|
@ -107,6 +110,7 @@ public class CertificateCreationService {
|
||||||
certificateExtension.setValue(String.join(",", extension.getAlternativeDnsNames()));
|
certificateExtension.setValue(String.join(",", extension.getAlternativeDnsNames()));
|
||||||
certificate.setCertificateExtension(List.of(certificateExtension));
|
certificate.setCertificateExtension(List.of(certificateExtension));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +123,7 @@ public class CertificateCreationService {
|
||||||
try {
|
try {
|
||||||
String fingerprint = openSSLService.getCertificateFingerprint(certificate);
|
String fingerprint = openSSLService.getCertificateFingerprint(certificate);
|
||||||
Certificate entity = createEntityFromInfo(openSSLService.getCertificateInfo(certificate));
|
Certificate entity = createEntityFromInfo(openSSLService.getCertificateInfo(certificate));
|
||||||
|
entity.setRequestedKeyLength(-1);
|
||||||
entity.setFingerprint(fingerprint);
|
entity.setFingerprint(fingerprint);
|
||||||
entity.setCert(Files.readAllBytes(certificate));
|
entity.setCert(Files.readAllBytes(certificate));
|
||||||
if (keyFile != null) {
|
if (keyFile != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue