public class SSLContexts
extends java.lang.Object
SSLContext
.Modifier and Type | Method and Description |
---|---|
static javax.net.ssl.SSLContext |
sslContext(java.io.File keyStoreFile,
java.lang.String password)
Creates an SSL context using a password-protected keystore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.io.File keyStoreFile,
java.lang.String keyStorePassword,
java.io.File trustStoreFile,
java.lang.String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.io.InputStream keyStoreStream,
java.lang.String password)
Creates an SSL context using a password-protected keystore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.io.InputStream keyStoreStream,
java.lang.String keyStorePassword,
java.io.InputStream trustStoreStream,
java.lang.String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.nio.file.Path keyStoreFile,
java.lang.String password)
Creates an SSL context using a password-protected keystore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.nio.file.Path keyStoreFile,
java.lang.String keyStorePassword,
java.nio.file.Path trustStoreFile,
java.lang.String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.net.URL keyStoreFile,
java.lang.String password)
Creates an SSL context using a password-protected keystore file.
|
static javax.net.ssl.SSLContext |
sslContext(java.net.URL keyStoreFile,
java.lang.String keyStorePassword,
java.net.URL trustStoreFile,
java.lang.String trustStorePassword)
Creates an SSL context using password protected keystore as well as password protected truststore file.
|
public static javax.net.ssl.SSLContext sslContext(java.net.URL keyStoreFile, java.lang.String password) throws java.security.GeneralSecurityException, java.io.IOException
keyStoreFile
- a file://
URL referencing a keystore filepassword
- the password for the keystore filejava.security.GeneralSecurityException
- if the keystore is invalid, or the password is incorrectjava.io.IOException
- if the url cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.net.URL keyStoreFile, java.lang.String keyStorePassword, java.net.URL trustStoreFile, java.lang.String trustStorePassword) throws java.security.GeneralSecurityException, java.io.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 filejava.security.GeneralSecurityException
- if either the keystore or truststore is invalid, or the password is incorrectjava.io.IOException
- if any of the urls cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.io.File keyStoreFile, java.lang.String password) throws java.security.GeneralSecurityException, java.io.IOException
keyStoreFile
- a keystore filepassword
- the password for the keystore filejava.security.GeneralSecurityException
- if the keystore is invalid, or the password is incorrectjava.io.IOException
- if the url cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.io.File keyStoreFile, java.lang.String keyStorePassword, java.io.File trustStoreFile, java.lang.String trustStorePassword) throws java.security.GeneralSecurityException, java.io.IOException
keyStoreFile
- a keystore filekeyStorePassword
- the pasword for the keystore filetrustStoreFile
- a truststore filetrustStorePassword
- the password for the truststore filejava.security.GeneralSecurityException
- if either the keystore or truststore is invalid, or the password is incorrectjava.io.IOException
- if any of the urls cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.nio.file.Path keyStoreFile, java.lang.String password) throws java.security.GeneralSecurityException, java.io.IOException
keyStoreFile
- a keystore filepassword
- the password for the keystore filejava.security.GeneralSecurityException
- if the keystore is invalid, or the password is incorrectjava.io.IOException
- if the url cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.nio.file.Path keyStoreFile, java.lang.String keyStorePassword, java.nio.file.Path trustStoreFile, java.lang.String trustStorePassword) throws java.security.GeneralSecurityException, java.io.IOException
keyStoreFile
- a keystore filekeyStorePassword
- the password for the keystore filetrustStoreFile
- a truststore filetrustStorePassword
- the password for the truststore filejava.security.GeneralSecurityException
- if either the keystore or the truststore is invalid, or the password is incorrectjava.io.IOException
- if any of the urls cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.io.InputStream keyStoreStream, java.lang.String password) throws java.security.GeneralSecurityException, java.io.IOException
keyStoreStream
- an input stream reading a keystore filepassword
- the password for the keystore filejava.security.GeneralSecurityException
- if the keystore is invalid, or the password is incorrectjava.io.IOException
- if the url cannot be readpublic static javax.net.ssl.SSLContext sslContext(java.io.InputStream keyStoreStream, java.lang.String keyStorePassword, java.io.InputStream trustStoreStream, java.lang.String trustStorePassword) throws java.security.GeneralSecurityException, java.io.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 filejava.security.GeneralSecurityException
- if either the keystore or the truststore is invalid, or the password is incorrectjava.io.IOException
- if any of the urls cannot be read