feat: Allow certification results to be usages
This commit is contained in:
parent
fc34320ffd
commit
1d6bf0facc
2 changed files with 31 additions and 7 deletions
|
@ -90,7 +90,13 @@ public class OpenSSLCertificateCreator {
|
||||||
|
|
||||||
try (var certAuthority = certificateProvider.requestCertificateUsage(request.getTrustingAuthority())) {
|
try (var certAuthority = certificateProvider.requestCertificateUsage(request.getTrustingAuthority())) {
|
||||||
Path unsignedCert = createSigningRequest(request, keyFile, tmpDir.resolve("child.csr"), certPassword);
|
Path unsignedCert = createSigningRequest(request, keyFile, tmpDir.resolve("child.csr"), certPassword);
|
||||||
Path signedCert = signCertificate(request, certAuthority.certificatePath(), certAuthority.certificateKeyPath(), unsignedCert, certPassword);
|
Path signedCert = signCertificate(
|
||||||
|
request,
|
||||||
|
certAuthority.certificatePath(),
|
||||||
|
certAuthority.certificateKeyPath(),
|
||||||
|
unsignedCert,
|
||||||
|
certPassword
|
||||||
|
);
|
||||||
String fingerprint = getCertificateFingerprint(signedCert);
|
String fingerprint = getCertificateFingerprint(signedCert);
|
||||||
passwordProvider.setPasswordFor(fingerprint, certPassword);
|
passwordProvider.setPasswordFor(fingerprint, certPassword);
|
||||||
return new OpenSSLCertificateResult(tmpDir, signedCert, keyFile, fingerprint);
|
return new OpenSSLCertificateResult(tmpDir, signedCert, keyFile, fingerprint);
|
||||||
|
|
|
@ -12,8 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
@Getter
|
public class OpenSSLCertificateResult implements CertificateUsage {
|
||||||
public class OpenSSLCertificateResult implements AutoCloseable {
|
|
||||||
|
|
||||||
private final Path tmpDir;
|
private final Path tmpDir;
|
||||||
private final Path certificatePath;
|
private final Path certificatePath;
|
||||||
|
@ -21,9 +20,28 @@ public class OpenSSLCertificateResult implements AutoCloseable {
|
||||||
private final String certificateFingerPrint;
|
private final String certificateFingerPrint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public Path certificatePath() {
|
||||||
|
return certificatePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path certificateKeyPath() {
|
||||||
|
return privateKeyPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String fingerprint() {
|
||||||
|
return certificateFingerPrint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
try {
|
||||||
log.info("Cleaning up temporary output directory {}", tmpDir);
|
log.info("Cleaning up temporary output directory {}", tmpDir);
|
||||||
Files.walkFileTree(tmpDir, Set.of(), Integer.MAX_VALUE, new DeleteRecursiveFileVisitor());
|
Files.walkFileTree(tmpDir, Set.of(), Integer.MAX_VALUE, new DeleteRecursiveFileVisitor());
|
||||||
Files.deleteIfExists(tmpDir);
|
Files.deleteIfExists(tmpDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Failed to clean up temporary output directory {}!", tmpDir, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue