Skip to content

Commit

Permalink
Support FIPS mode in kubernetes-client with BouncyCastleFipsProvider …
Browse files Browse the repository at this point in the history
…connected externally
  • Loading branch information
gulyaev13 authored and manusa committed Apr 7, 2021
1 parent e509684 commit eb18f9f
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static char[] getTrustStorePassphrase(String trustStorePassphrase) {
}

public static KeyStore createTrustStore(InputStream pemInputStream, String trustStoreFile, char[] trustStorePassphrase) throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException {
KeyStore trustStore = KeyStore.getInstance("JKS");
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());

if (Utils.isNotNullOrEmpty(trustStoreFile)) {
trustStore.load(new FileInputStream(trustStoreFile), trustStorePassphrase);
Expand All @@ -112,7 +112,7 @@ public static KeyStore createKeyStore(InputStream certInputStream, InputStream k
Collection<? extends Certificate> certificates = certFactory.generateCertificates(certInputStream);
PrivateKey privateKey = loadKey(keyInputStream, clientKeyAlgo);

KeyStore keyStore = KeyStore.getInstance("JKS");
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
if (Utils.isNotNullOrEmpty(keyStoreFile)){
keyStore.load(new FileInputStream(keyStoreFile), keyStorePassphrase);
} else {
Expand Down Expand Up @@ -145,7 +145,7 @@ private static PrivateKey handleECKey(InputStream keyInputStream) throws IOExcep
@Override
public PrivateKey call() {
try {
if (Security.getProvider("BC") == null) {
if (Security.getProvider("BC") == null && Security.getProvider("BCFIPS") == null) {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
}
PEMKeyPair keys = (PEMKeyPair) new PEMParser(new InputStreamReader(keyInputStream)).readObject();
Expand Down

0 comments on commit eb18f9f

Please sign in to comment.