public class SSLContexts extends Object
SSLContext
.Modifier and Type | Method and Description |
---|---|
static SSLContext |
sslContext(File keyStoreFile,
String password)
Creates an SSL context using a password-protected keystore file.
|
static SSLContext |
sslContext(File keyStoreFile,
String keyStorePassword,
File trustStoreFile,
String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
static SSLContext |
sslContext(InputStream keyStoreStream,
String password)
Creates an SSL context using a password-protected keystore file.
|
static SSLContext |
sslContext(InputStream keyStoreStream,
String keyStorePassword,
InputStream trustStoreStream,
String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
static SSLContext |
sslContext(Path keyStoreFile,
String password)
Creates an SSL context using a password-protected keystore file.
|
static SSLContext |
sslContext(Path keyStoreFile,
String keyStorePassword,
Path trustStoreFile,
String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
static SSLContext |
sslContext(URL keyStoreFile,
String password)
Creates an SSL context using a password-protected keystore file.
|
static SSLContext |
sslContext(URL keyStoreFile,
String keyStorePassword,
URL trustStoreFile,
String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
public static SSLContext sslContext(URL keyStoreFile, String password) throws GeneralSecurityException, IOException
keyStoreFile
- a file://
URL referencing a keystore filepassword
- the password for the keystore fileGeneralSecurityException
- if the keystore is invalid, or the password is incorrectIOException
- if the url cannot be readpublic static SSLContext sslContext(URL keyStoreFile, String keyStorePassword, URL trustStoreFile, String trustStorePassword) throws GeneralSecurityException, IOException
keyStoreFile
- a file://
URL referencing a keystore filekeyStorePassword
- the password for the keystore filetrustStoreFile
- a file://
URL referencing a truststore filetrustStorePassword
- the password for the truststore fileGeneralSecurityException
- if either the keystore or truststore is invalid, or the password is incorrectIOException
- if any of the urls cannot be readpublic static SSLContext sslContext(File keyStoreFile, String password) throws GeneralSecurityException, IOException
keyStoreFile
- a keystore filepassword
- the password for the keystore fileGeneralSecurityException
- if the keystore is invalid, or the password is incorrectIOException
- if the url cannot be readpublic static SSLContext sslContext(File keyStoreFile, String keyStorePassword, File trustStoreFile, String trustStorePassword) throws GeneralSecurityException, IOException
keyStoreFile
- a keystore filekeyStorePassword
- the pasword for the keystore filetrustStoreFile
- a truststore filetrustStorePassword
- the password for the truststore fileGeneralSecurityException
- if either the keystore or truststore is invalid, or the password is incorrectIOException
- if any of the urls cannot be readpublic static SSLContext sslContext(Path keyStoreFile, String password) throws GeneralSecurityException, IOException
keyStoreFile
- a keystore filepassword
- the password for the keystore fileGeneralSecurityException
- if the keystore is invalid, or the password is incorrectIOException
- if the url cannot be readpublic static SSLContext sslContext(Path keyStoreFile, String keyStorePassword, Path trustStoreFile, String trustStorePassword) throws GeneralSecurityException, IOException
keyStoreFile
- a keystore filekeyStorePassword
- the password for the keystore filetrustStoreFile
- a truststore filetrustStorePassword
- the password for the truststore fileGeneralSecurityException
- if either the keystore or the truststore is invalid, or the password is incorrectIOException
- if any of the urls cannot be readpublic static SSLContext sslContext(InputStream keyStoreStream, String password) throws GeneralSecurityException, IOException
keyStoreStream
- an input stream reading a keystore filepassword
- the password for the keystore fileGeneralSecurityException
- if the keystore is invalid, or the password is incorrectIOException
- if the url cannot be readpublic static SSLContext sslContext(InputStream keyStoreStream, String keyStorePassword, InputStream trustStoreStream, String trustStorePassword) throws GeneralSecurityException, IOException
In SSL handshake the purpose of of keystore is to provide credentials, while the purpose of truststore is to verify credentials.
Trustore stores certificates from thrid parties that application trusts or certificates signed by CA that can be used to identify third party. Keystore stores private key and public key that are used to generate certificates exposed to clients or used in client SSL authentication.
keyStoreStream
- an input stream reading keystore filekeyStorePassword
- the password for the keystore filetrustStoreStream
- an input stream reading truststore filetrustStorePassword
- the password for the truststore fileGeneralSecurityException
- if either the keystore or the truststore is invalid, or the password is incorrectIOException
- if any of the urls cannot be read