Skip to content

Commit

Permalink
Merge pull request fabric8io#2164 from minsheng-fintech-corp-ltd/rui.…
Browse files Browse the repository at this point in the history
…zou/fix-auth
  • Loading branch information
fusesource-ci authored Apr 27, 2020
2 parents b0eae8e + 268cd34 commit a97aeb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 4.9-SNAPSHOT
#### Bugs
* Fix #2163: fix kubernetes-client not support cert chain
* Fix #2144: CRD's schema Default fields do not handle boolean and are prefixed with Raw keyword
* KubernetesAttributeExtractor: handle possible /status subpath due to using status subresource on crd
* Fix #2124: Raw Watch on CustomResource does not work if name specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateCrtKeySpec;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;

public class CertUtils {

Expand Down Expand Up @@ -107,7 +109,7 @@ public static KeyStore createTrustStore(InputStream pemInputStream, String trust

public static KeyStore createKeyStore(InputStream certInputStream, InputStream keyInputStream, String clientKeyAlgo, char[] clientKeyPassphrase, String keyStoreFile, char[] keyStorePassphrase) throws IOException, CertificateException, NoSuchAlgorithmException, InvalidKeySpecException, KeyStoreException {
CertificateFactory certFactory = CertificateFactory.getInstance("X509");
X509Certificate cert = (X509Certificate) certFactory.generateCertificate(certInputStream);
Collection<? extends Certificate> certificates = certFactory.generateCertificates(certInputStream);
PrivateKey privateKey = loadKey(keyInputStream, clientKeyAlgo);

KeyStore keyStore = KeyStore.getInstance("JKS");
Expand All @@ -117,8 +119,8 @@ public static KeyStore createKeyStore(InputStream certInputStream, InputStream k
loadDefaultKeyStoreFile(keyStore, keyStorePassphrase);
}

String alias = cert.getSubjectX500Principal().getName();
keyStore.setKeyEntry(alias, privateKey, clientKeyPassphrase, new Certificate[]{cert});
String alias = certificates.stream().map(cert->((X509Certificate)cert).getIssuerX500Principal().getName()).collect(Collectors.joining("_"));
keyStore.setKeyEntry(alias, privateKey, clientKeyPassphrase, certificates.toArray(new Certificate[0]));

return keyStore;
}
Expand Down

0 comments on commit a97aeb9

Please sign in to comment.