mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
perf(build): replace BouncyCastle with JDK crypto API as much as possible (#2988)
* perf(security): stop registering the BouncyCastle JCE provider ACM signs through the JDK and builds PBES2 there, and KMS PSS uses RSASSA-PSS with the parameters AWS specifies. Downsize Docker image from 88.7 to 83.9 MB gzipped. * test(compat): verify the native image's KMS and ACM crypto from outside Floci Floci verifying its own signature proves nothing. Signatures now check against GetPublicKey with an outside library, exported keys are decrypted, and issued certificates verify their own signature. * fix(kms): apply real PSS padding when signing a digest with RSASSA_PSS * fix(acm): set the PBES2 salt and iteration count explicitly * perf(kms): reuse the shared SecureRandom when signing a PSS digest * fix(kms): let AwsException pass through the sign and verify catch blocks * perf(native): drop the native-image config the BouncyCastle provider needed Five --initialize-at-run-time entries and 21 reflect-config entries existed for the BouncyCastle JCE provider. Nothing registers that provider any more, so they only kept dead initialization code in the image. The run-time initialization entries are what cost size. Removing them takes the binary from 204.6 to 203.1 MB and gzip -9 from 79.5 to 78.9 MB. The reflect-config entries measured as noise, because those classes stay registered through another path, but they still describe a provider Floci no longer installs. Verified on a native build. The Python suite passes 354 tests, the Java SDK suite passes 61 including CloudHSM v2 and ACM, and a TLS run generates its self-signed certificate and signs with secp256k1 over HTTPS.
This commit is contained in:
1 parent
21f165b2e9
commit
ffe8a92635
10 files changed
+313
-267
No files matched your search
@@ -3,7 +3,6 @@ package io.github.hectorvent.floci.config;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.services.acm.CertificateGenerator;
|
||||
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.eclipse.microprofile.config.spi.ConfigSource;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
@@ -19,7 +18,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.security.Security;
|
||||
|
||||
/**
|
||||
* A MicroProfile {@link ConfigSource} that dynamically provides Quarkus TLS/SSL
|
||||
@@ -65,13 +63,6 @@ public class TlsConfigSource implements ConfigSource {
|
||||
return;
|
||||
}
|
||||
|
||||
// BouncyCastle may not be registered yet — this ConfigSource runs before CDI (@Startup beans)
|
||||
// and before quarkus-security's runtime provider registration. Register it up front so BOTH
|
||||
// certificate parsing (isSelfSigned/parseCertificate) and generation work; otherwise
|
||||
// parseCertificate fails "no such provider: BC", isSelfSigned returns false, and the persisted
|
||||
// self-signed certificate is needlessly regenerated on every restart.
|
||||
ensureBouncyCastleRegistered();
|
||||
|
||||
String certPath = resolveProperty("floci.tls.cert-path", "");
|
||||
String keyPath = resolveProperty("floci.tls.key-path", "");
|
||||
String selfSigned = resolveProperty("floci.tls.self-signed", "true");
|
||||
@@ -171,16 +162,9 @@ public class TlsConfigSource implements ConfigSource {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static void ensureBouncyCastleRegistered() {
|
||||
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
}
|
||||
}
|
||||
|
||||
private void generateSelfSignedCert(Path tlsDir, Path certFile, Path keyFile) {
|
||||
try {
|
||||
Files.createDirectories(tlsDir);
|
||||
ensureBouncyCastleRegistered();
|
||||
|
||||
// Extract custom hostnames and combine with defaults
|
||||
List<String> customHostnames = extractCustomHostnames();
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import io.quarkus.runtime.Startup;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
/**
|
||||
* Ensures BouncyCastle security provider is registered.
|
||||
* With quarkus-security extension and quarkus.security.security-providers=BC,
|
||||
* this is handled by Quarkus.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
@Startup
|
||||
public class BouncyCastleInitializer {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(BouncyCastleInitializer.class);
|
||||
|
||||
static {
|
||||
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
LOG.debug("Registered BouncyCastle security provider (manual fallback)");
|
||||
} else {
|
||||
LOG.debug("BouncyCastle provider already registered by Quarkus");
|
||||
}
|
||||
}
|
||||
|
||||
public BouncyCastleInitializer() {
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package io.github.hectorvent.floci.services.acm;
|
||||
|
||||
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
|
||||
import org.bouncycastle.asn1.ASN1Primitive;
|
||||
import org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo;
|
||||
import org.bouncycastle.asn1.x500.X500Name;
|
||||
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
||||
import org.bouncycastle.asn1.x509.BasicConstraints;
|
||||
import org.bouncycastle.asn1.x509.Extension;
|
||||
import org.bouncycastle.asn1.x509.GeneralName;
|
||||
@@ -13,7 +15,6 @@ import org.bouncycastle.cert.X509CertificateHolder;
|
||||
import org.bouncycastle.cert.X509v3CertificateBuilder;
|
||||
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
|
||||
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.openssl.PEMParser;
|
||||
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
|
||||
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
|
||||
@@ -21,12 +22,13 @@ import org.bouncycastle.openssl.jcajce.JcePEMEncryptorBuilder;
|
||||
import org.bouncycastle.operator.ContentSigner;
|
||||
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
||||
import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo;
|
||||
import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder;
|
||||
import org.bouncycastle.pkcs.jcajce.JcaPKCS8EncryptedPrivateKeyInfoBuilder;
|
||||
import org.bouncycastle.pkcs.jcajce.JcePKCSPBEOutputEncryptorBuilder;
|
||||
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
@@ -52,6 +54,9 @@ public class CertificateGenerator {
|
||||
private static final Logger LOG = Logger.getLogger(CertificateGenerator.class);
|
||||
private static final String ISSUER_DN = "CN=Amazon,OU=Server CA 1B,O=Amazon,C=US";
|
||||
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||
private static final String PBE_ALGORITHM = "PBEWithHmacSHA256AndAES_256";
|
||||
private static final int PBE_SALT_BYTES = 16;
|
||||
private static final int PBE_ITERATIONS = 4096;
|
||||
|
||||
/**
|
||||
* Pattern matching IPv4 addresses (e.g. 192.168.1.100) and IPv6 addresses
|
||||
@@ -166,12 +171,10 @@ public class CertificateGenerator {
|
||||
// a cosmetic Amazon DN (mimicking ACM); for generateSelfSignedCertificate() issuer ==
|
||||
// subject, so the cert is a valid self-signed trust anchor.
|
||||
ContentSigner signer = new JcaContentSignerBuilder(signatureAlgorithm)
|
||||
.setProvider(BouncyCastleProvider.PROVIDER_NAME)
|
||||
.build(keyPair.getPrivate());
|
||||
|
||||
X509CertificateHolder certHolder = certBuilder.build(signer);
|
||||
X509Certificate cert = new JcaX509CertificateConverter()
|
||||
.setProvider(BouncyCastleProvider.PROVIDER_NAME)
|
||||
.getCertificate(certHolder);
|
||||
|
||||
String certPem = toPem(cert);
|
||||
@@ -197,10 +200,10 @@ public class CertificateGenerator {
|
||||
private KeyPair generateKeyPair(KeyAlgorithm keyAlgorithm) throws Exception {
|
||||
KeyPairGenerator keyGen;
|
||||
if ("EC".equals(keyAlgorithm.getAlgorithm())) {
|
||||
keyGen = KeyPairGenerator.getInstance("EC", BouncyCastleProvider.PROVIDER_NAME);
|
||||
keyGen = KeyPairGenerator.getInstance("EC");
|
||||
keyGen.initialize(new ECGenParameterSpec(keyAlgorithm.getCurveName()), SECURE_RANDOM);
|
||||
} else {
|
||||
keyGen = KeyPairGenerator.getInstance("RSA", BouncyCastleProvider.PROVIDER_NAME);
|
||||
keyGen = KeyPairGenerator.getInstance("RSA");
|
||||
keyGen.initialize(keyAlgorithm.getKeySize(), SECURE_RANDOM);
|
||||
}
|
||||
return keyGen.generateKeyPair();
|
||||
@@ -260,16 +263,24 @@ public class CertificateGenerator {
|
||||
try {
|
||||
PrivateKey privateKey = parsePrivateKey(privateKeyPem);
|
||||
|
||||
// Use AES-256-CBC instead of deprecated Triple-DES
|
||||
JcePKCSPBEOutputEncryptorBuilder encryptorBuilder = new JcePKCSPBEOutputEncryptorBuilder(
|
||||
NISTObjectIdentifiers.id_aes256_CBC
|
||||
);
|
||||
encryptorBuilder.setProvider(BouncyCastleProvider.PROVIDER_NAME);
|
||||
// PBES2 with AES-256-CBC, run through the JDK so no JCE provider has to be
|
||||
// registered. The algorithm name fixes the PBKDF2 PRF to HMAC-SHA256, and the
|
||||
// salt and iteration count are passed explicitly so the output does not depend
|
||||
// on provider defaults. The ASN.1 below only wraps the result, so it needs no
|
||||
// provider either.
|
||||
var secretKey = SecretKeyFactory.getInstance(PBE_ALGORITHM)
|
||||
.generateSecret(new PBEKeySpec(passphrase.toCharArray()));
|
||||
var salt = new byte[PBE_SALT_BYTES];
|
||||
SECURE_RANDOM.nextBytes(salt);
|
||||
var cipher = Cipher.getInstance(PBE_ALGORITHM);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, new PBEParameterSpec(salt, PBE_ITERATIONS));
|
||||
var ciphertext = cipher.doFinal(privateKey.getEncoded());
|
||||
|
||||
PKCS8EncryptedPrivateKeyInfoBuilder pkcs8Builder = new JcaPKCS8EncryptedPrivateKeyInfoBuilder(privateKey);
|
||||
PKCS8EncryptedPrivateKeyInfo encryptedInfo = pkcs8Builder.build(
|
||||
encryptorBuilder.build(passphrase.toCharArray())
|
||||
);
|
||||
var scheme = new AlgorithmIdentifier(
|
||||
PKCSObjectIdentifiers.id_PBES2,
|
||||
ASN1Primitive.fromByteArray(cipher.getParameters().getEncoded()));
|
||||
var encryptedInfo =
|
||||
new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(scheme, ciphertext));
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
try (JcaPEMWriter pemWriter = new JcaPEMWriter(sw)) {
|
||||
@@ -288,7 +299,6 @@ public class CertificateGenerator {
|
||||
Object obj = parser.readObject();
|
||||
if (obj instanceof X509CertificateHolder holder) {
|
||||
return new JcaX509CertificateConverter()
|
||||
.setProvider(BouncyCastleProvider.PROVIDER_NAME)
|
||||
.getCertificate(holder);
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid certificate PEM format");
|
||||
@@ -301,8 +311,7 @@ public class CertificateGenerator {
|
||||
public PrivateKey parsePrivateKey(String keyPem) {
|
||||
try (PEMParser parser = new PEMParser(new StringReader(keyPem))) {
|
||||
Object obj = parser.readObject();
|
||||
JcaPEMKeyConverter converter = new JcaPEMKeyConverter()
|
||||
.setProvider(BouncyCastleProvider.PROVIDER_NAME);
|
||||
JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
|
||||
|
||||
if (obj instanceof org.bouncycastle.openssl.PEMKeyPair pemKeyPair) {
|
||||
return converter.getKeyPair(pemKeyPair).getPrivate();
|
||||
|
||||
@@ -29,6 +29,11 @@ import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
|
||||
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
||||
import org.bouncycastle.asn1.x509.DigestInfo;
|
||||
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
||||
import org.bouncycastle.crypto.Digest;
|
||||
import org.bouncycastle.crypto.digests.SHA256Digest;
|
||||
import org.bouncycastle.crypto.digests.SHA384Digest;
|
||||
import org.bouncycastle.crypto.digests.SHA512Digest;
|
||||
import org.bouncycastle.crypto.engines.RSABlindedEngine;
|
||||
import org.bouncycastle.crypto.params.ECDomainParameters;
|
||||
import org.bouncycastle.crypto.params.Ed25519PublicKeyParameters;
|
||||
import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters;
|
||||
@@ -37,6 +42,9 @@ import org.bouncycastle.crypto.params.ECPublicKeyParameters;
|
||||
import org.bouncycastle.crypto.params.ParametersWithRandom;
|
||||
import org.bouncycastle.crypto.signers.ECDSASigner;
|
||||
import org.bouncycastle.crypto.signers.Ed25519phSigner;
|
||||
import org.bouncycastle.crypto.signers.PSSSigner;
|
||||
import org.bouncycastle.crypto.util.PrivateKeyFactory;
|
||||
import org.bouncycastle.crypto.util.PublicKeyFactory;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi;
|
||||
@@ -56,7 +64,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.security.interfaces.EdECPrivateKey;
|
||||
import java.security.spec.ECGenParameterSpec;
|
||||
import java.security.spec.MGF1ParameterSpec;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.PSSParameterSpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
@@ -948,6 +958,9 @@ public class KmsService implements ResourceProvider {
|
||||
if (ed25519) {
|
||||
return signEd25519(privateKey, message, algorithm);
|
||||
}
|
||||
if (messageType == DIGEST && isRsaPssRequest(kmsKey.getKeySpec(), algorithm)) {
|
||||
return signRsaPssDigest(privateKey, message, algorithm);
|
||||
}
|
||||
String jcaAlgo = switch (messageType) {
|
||||
// If message is already a digest, we need a "NONEwith..." algorithm
|
||||
case DIGEST -> "NONEwith" + (kmsKey.getKeySpec().getKeyType() == KmsKeySpec.KeyType.RSA ? "RSA" : "ECDSA");
|
||||
@@ -962,10 +975,12 @@ public class KmsService implements ResourceProvider {
|
||||
if (isSecgP256k1(kmsKey.getKeySpec())) {
|
||||
return signSecgP256k1(privateKey, message, jcaAlgo);
|
||||
}
|
||||
Signature sig = Signature.getInstance(jcaAlgo);
|
||||
var sig = signatureFor(jcaAlgo);
|
||||
sig.initSign(privateKey);
|
||||
sig.update(message);
|
||||
return sig.sign();
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new AwsException("InternalFailure", "Failed to sign message: " + e.getMessage(), 500);
|
||||
}
|
||||
@@ -994,6 +1009,9 @@ public class KmsService implements ResourceProvider {
|
||||
String jcaAlgo = KmsKeySpec.getSignVerifyAlgorithm(algorithm).getJavaName();
|
||||
|
||||
if (DIGEST.equals(messageType)) {
|
||||
if (isRsaPssRequest(kmsKey.getKeySpec(), algorithm)) {
|
||||
return verifyRsaPssDigest(publicKey, message, signature, algorithm);
|
||||
}
|
||||
jcaAlgo = "NONEwith" + (kmsKey.getKeySpec().getKeyType() == KmsKeySpec.KeyType.RSA ? "RSA" : "ECDSA");
|
||||
if (isPKCS1v1_5(kmsKey.getKeySpec().getAlgorithm().getFirst())) {
|
||||
// Mirror sign(): verify against DigestInfo{hashOID, digest} (RFC 8017 9.2).
|
||||
@@ -1003,10 +1021,12 @@ public class KmsService implements ResourceProvider {
|
||||
if (isSecgP256k1(kmsKey.getKeySpec())) {
|
||||
return verifySecgP256k1(publicKey, message, signature, jcaAlgo);
|
||||
}
|
||||
Signature sig = Signature.getInstance(jcaAlgo);
|
||||
var sig = signatureFor(jcaAlgo);
|
||||
sig.initVerify(publicKey);
|
||||
sig.update(message);
|
||||
return sig.verify(signature);
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Verification failed for key {0}: {1}", keyId, e.getMessage());
|
||||
return false;
|
||||
@@ -1265,6 +1285,71 @@ public class KmsService implements ResourceProvider {
|
||||
return SubjectPublicKeyInfo.getInstance(publicKey.getEncoded()).getPublicKeyData().getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the {@link Signature} for a KMS signing algorithm.
|
||||
*
|
||||
* <p>BouncyCastle names PSS signatures {@code SHAnnnwithRSA/PSS}, and only its provider
|
||||
* answers to that name. The JDK exposes one {@code RSASSA-PSS} Signature whose digest,
|
||||
* mask generation function and salt length come from a parameter spec instead. AWS KMS
|
||||
* RSASSA_PSS_SHA_nnn uses MGF1 over the same digest with a salt as long as that digest,
|
||||
* which is what BouncyCastle's alias defaults to, so a signature made either way verifies
|
||||
* against the other. Every other name Floci asks for is a standard JCA name.
|
||||
*/
|
||||
private static Signature signatureFor(String jcaAlgorithm) throws GeneralSecurityException {
|
||||
if (!jcaAlgorithm.endsWith("withRSA/PSS")) {
|
||||
return Signature.getInstance(jcaAlgorithm);
|
||||
}
|
||||
var digest = "SHA-" + jcaAlgorithm.substring("SHA".length(), jcaAlgorithm.indexOf("with"));
|
||||
var maskGeneration = switch (digest) {
|
||||
case "SHA-256" -> MGF1ParameterSpec.SHA256;
|
||||
case "SHA-384" -> MGF1ParameterSpec.SHA384;
|
||||
case "SHA-512" -> MGF1ParameterSpec.SHA512;
|
||||
default -> throw new NoSuchAlgorithmException("Unsupported PSS digest: " + digest);
|
||||
};
|
||||
var saltLength = MessageDigest.getInstance(digest).getDigestLength();
|
||||
var signature = Signature.getInstance("RSASSA-PSS");
|
||||
signature.setParameter(new PSSParameterSpec(digest, "MGF1", maskGeneration, saltLength, 1));
|
||||
return signature;
|
||||
}
|
||||
|
||||
private static boolean isRsaPssRequest(KmsKeySpec spec, String algorithm) {
|
||||
return spec.getKeyType() == KmsKeySpec.KeyType.RSA && algorithm.startsWith("RSASSA_PSS");
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs a pre-computed digest with RSASSA-PSS.
|
||||
*
|
||||
* <p>Real KMS applies the PSS encoding directly to the digest a {@code MessageType=DIGEST}
|
||||
* caller sends. The JDK's {@code RSASSA-PSS} Signature always hashes its input first, so
|
||||
* this uses BouncyCastle's lightweight raw PSS signer, instantiated directly like the
|
||||
* secp256k1 and Ed25519ph paths. The raw signer defaults to MGF1 over the same digest with
|
||||
* a salt as long as that digest, matching {@link #signatureFor(String)}, so RAW and DIGEST
|
||||
* signatures verify against each other.
|
||||
*/
|
||||
private static byte[] signRsaPssDigest(PrivateKey privateKey, byte[] digest, String algorithm) throws Exception {
|
||||
var signer = rawPssSigner(algorithm);
|
||||
signer.init(true, new ParametersWithRandom(PrivateKeyFactory.createKey(privateKey.getEncoded()), SECURE_RANDOM));
|
||||
signer.update(digest, 0, digest.length);
|
||||
return signer.generateSignature();
|
||||
}
|
||||
|
||||
private static boolean verifyRsaPssDigest(PublicKey publicKey, byte[] digest, byte[] signature, String algorithm) throws Exception {
|
||||
var signer = rawPssSigner(algorithm);
|
||||
signer.init(false, PublicKeyFactory.createKey(publicKey.getEncoded()));
|
||||
signer.update(digest, 0, digest.length);
|
||||
return signer.verifySignature(signature);
|
||||
}
|
||||
|
||||
private static PSSSigner rawPssSigner(String algorithm) {
|
||||
Digest digest = switch (algorithm) {
|
||||
case "RSASSA_PSS_SHA_256" -> new SHA256Digest();
|
||||
case "RSASSA_PSS_SHA_384" -> new SHA384Digest();
|
||||
case "RSASSA_PSS_SHA_512" -> new SHA512Digest();
|
||||
default -> throw new AwsException("InvalidSigningAlgorithmException", "Unsupported algorithm: " + algorithm, 400);
|
||||
};
|
||||
return PSSSigner.createRawSigner(new RSABlindedEngine(), digest);
|
||||
}
|
||||
|
||||
private static boolean isPKCS1v1_5(KmsKeySpec.Algorithm spec) {
|
||||
return spec == KmsKeySpec.Algorithm.RSASSA_PKCS1_V1_5_SHA_256
|
||||
|| spec == KmsKeySpec.Algorithm.RSASSA_PKCS1_V1_5_SHA_384
|
||||
|
||||
-9
@@ -7,7 +7,6 @@ import io.github.hectorvent.floci.services.acm.CertificateGenerator;
|
||||
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
@@ -21,7 +20,6 @@ import java.security.KeyPair;
|
||||
import java.security.KeyStore;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -108,7 +106,6 @@ public class RdsProxyTlsCertificates {
|
||||
if (sslContext != null) {
|
||||
return;
|
||||
}
|
||||
ensureBouncyCastleRegistered();
|
||||
Path tlsDir = tlsDir();
|
||||
Path certFile = tlsDir.resolve(CERT_NAME);
|
||||
Path keyFile = tlsDir.resolve(KEY_NAME);
|
||||
@@ -195,12 +192,6 @@ public class RdsProxyTlsCertificates {
|
||||
return Path.of(config.storage().persistentPath(), TLS_DIR);
|
||||
}
|
||||
|
||||
private static void ensureBouncyCastleRegistered() {
|
||||
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts {@code path} to owner-only access. This CA's private key is meant to be trusted by
|
||||
* a developer's client tooling (e.g. {@code sslmode=verify-full}), so unlike Floci's other
|
||||
|
||||
Reference in new issue
Block a user