public final class UtilSsl extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UtilSsl.EKeystoreExtensions |
static class |
UtilSsl.EKeystoreInstances |
Modifier and Type | Method and Description |
---|---|
static UtilSsl.EKeystoreInstances |
getKeystoreInstance(Path keystore)
Provide the keystore type according to its extension among jks or p12
|
static KeyStore |
getStoreFromPath(Path keystore,
String password)
Load a keystore from path
Password can be null if no password is securing the keystore
|
static KeyStore |
loadKeyStore(Path certificate,
Path privateKey,
String keyPassword,
String keyAlias)
Generate a java keystore (JKS type) from a private key and a certificate files
Be sure to provide only related key and cert file to generate a keystore
|
static SSLContext |
loadSslContext(KeyStore truststore,
KeyStore keyStore,
String KeyStorePass)
Load an ssl context for tls connexions using provided optional keystore and truststore
You may provide a keystore if you have to authenticate to a service that requires a certificate and a key for
incoming tls connexions
Keystore password can be null if no password actually protects the keystore
You may provide a truststore if you have to authenticate incoming tls connexions with a certificate
|
static KeyStore |
loadTrustStore(Path certificateChainFile)
Generate truststore form a certificate file or a chain
|
public static KeyStore loadTrustStore(Path certificateChainFile) throws IOException, GeneralSecurityException
certificateChainFile
- CA fileIOException
- .GeneralSecurityException
- .public static KeyStore loadKeyStore(Path certificate, Path privateKey, String keyPassword, String keyAlias) throws IOException, GeneralSecurityException
certificate
- public key fileprivateKey
- private key file related to the signed certificate in CA filekeyPassword
- password of the private key. This password will be reused to protect key in keystore.
Provide 'null' if key has no passwordIOException
- .GeneralSecurityException
- .public static UtilSsl.EKeystoreInstances getKeystoreInstance(Path keystore)
keystore
- path of a keystore with extensionpublic static KeyStore getStoreFromPath(Path keystore, String password)
keystore
- path to the keystore to loadpassword
- password of the keystore. Can be null if no passwordpublic static SSLContext loadSslContext(KeyStore truststore, KeyStore keyStore, String KeyStorePass) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException
truststore
- truststore of the ssl connexion. Can be null.keyStore
- keystore of the ssl connexion. Can be null.KeyStorePass
- password of the keystore. Can be null.NoSuchAlgorithmException
- .KeyStoreException
- .UnrecoverableKeyException
- .KeyManagementException
- .Copyright © 2014–2023. All rights reserved.