public class SSLConfig extends Object
$ keytool -printcert -file EquifaxSecureGlobaleBusinessCA-1.crt Owner: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Issuer: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Serial number: 1 Valid from: Mon Jun 21 00:00:00 EDT 1999 until: Sun Jun 21 00:00:00 EDT 2020 Certificate fingerprints: MD5: 8F:5D:77:06:27:C4:98:3C:5B:93:78:E7:D7:7D:9B:CC SHA1: 7E:78:4A:10:1C:82:65:CC:2D:E1:F1:6D:47:B4:40:CA:D9:0A:19:45 Signature algorithm name: MD5withRSA Version: 3 ....Now, import that into a Java keystore file:
$ keytool -importcert -alias "equifax-ca" -file EquifaxSecureGlobaleBusinessCA-1.crt -keystore truststore_javanet.jks -storepass test1234 Owner: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Issuer: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Serial number: 1 Valid from: Mon Jun 21 00:00:00 EDT 1999 until: Sun Jun 21 00:00:00 EDT 2020 Certificate fingerprints: MD5: 8F:5D:77:06:27:C4:98:3C:5B:93:78:E7:D7:7D:9B:CC SHA1: 7E:78:4A:10:1C:82:65:CC:2D:E1:F1:6D:47:B4:40:CA:D9:0A:19:45 Signature algorithm name: MD5withRSA Version: 3 ... Trust this certificate? [no]: yes Certificate was added to keystoreNow you want to use this truststore in your client:
RestAssured.config = RestAssured.newConfig().sslConfig(new SSLConfig("/truststore_javanet.jks", "test1234");or
given().config(newConfig().sslConfig(new SSLConfig("/truststore_javanet.jks", "test1234")). ..
Constructor and Description |
---|
SSLConfig()
Creates a new SSL Config instance with the following settings:
No keystore
No password
KeyStore.getDefaultType()
No explicit default port
No trust store
No SSLSocketFactory
SSLSocketFactory.STRICT_HOSTNAME_VERIFIER as X509HostnameVerifier implementation
|
Modifier and Type | Method and Description |
---|---|
SSLConfig |
allowAllHostnames()
Configure the SSLConfig to allow all host names.
|
SSLConfig |
and()
Syntactic sugar.
|
String |
getKeyStoreType() |
String |
getPassword() |
Object |
getPathToKeyStore() |
int |
getPort() |
org.apache.http.conn.ssl.SSLSocketFactory |
getSSLSocketFactory() |
KeyStore |
getTrustStore() |
org.apache.http.conn.ssl.X509HostnameVerifier |
getX509HostnameVerifier() |
boolean |
isUserConfigured() |
SSLConfig |
keystore(File pathToJks,
String password)
Use a keystore located on the file-system.
|
SSLConfig |
keystore(String password)
Uses the user default keystore stored in <user.home>/.keystore
|
SSLConfig |
keystore(String pathToJks,
String password) |
SSLConfig |
keystoreType(String keystoreType)
The certificate type, will use
KeyStore.getDefaultType() by default. |
SSLConfig |
port(int port)
The port for which REST Assured will apply the SSL configuration.
|
SSLConfig |
relaxedHTTPSValidation()
Use relaxed HTTP validation.
|
static SSLConfig |
sslConfig() |
SSLConfig |
sslSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory)
Specify a
SSLSocketFactory . |
SSLConfig |
strictHostnames()
Configure the SSLConfig to use strict host name verification (this is the default behavior).
|
SSLConfig |
trustStore(KeyStore trustStore)
A trust store to use during SSL/Certificate authentication.
|
SSLConfig |
using()
Syntactic sugar.
|
SSLConfig |
with()
Syntactic sugar.
|
SSLConfig |
x509HostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier x509HostnameVerifier)
Provide a custom
X509HostnameVerifier implementation that'll be used by the SSLSocketFactory . |
public SSLConfig()
KeyStore.getDefaultType()
SSLSocketFactory.STRICT_HOSTNAME_VERIFIER
as X509HostnameVerifier
implementationpublic SSLConfig keystore(String pathToJks, String password)
pathToJks
- The path to the JKS. REST Assured will first look in the classpath and if not found it will look for the JKS in the local file-systempassword
- The store passpublic SSLConfig keystore(File pathToJks, String password)
keystore(String, String)
for more details.pathToJks
- The path to JKS file on the file-systempassword
- The password for the keystorekeystore(String, String)
public SSLConfig keystore(String password)
password
- - Use null for no passwordpublic SSLConfig keystoreType(String keystoreType)
KeyStore.getDefaultType()
by default.keystoreType
- The keystore type.public SSLConfig port(int port)
port
- port.public SSLConfig trustStore(KeyStore trustStore)
trustStore
- The trust store to use.public SSLConfig relaxedHTTPSValidation()
keystore(String, String)
or trust store (see trustStore(java.security.KeyStore)
.public SSLConfig sslSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory)
SSLSocketFactory
. This will override settings from trust store as well as keystore and password.sslSocketFactory
- The SSLSocketFactory
to use.public SSLConfig x509HostnameVerifier(org.apache.http.conn.ssl.X509HostnameVerifier x509HostnameVerifier)
X509HostnameVerifier
implementation that'll be used by the SSLSocketFactory
. You can replace the
X509HostnameVerifier
for example if you want to allow all host names etc.x509HostnameVerifier
- The X509HostnameVerifier to use.allowAllHostnames()
,
strictHostnames()
public SSLConfig strictHostnames()
SSLSocketFactory.STRICT_HOSTNAME_VERIFIER
public SSLConfig allowAllHostnames()
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
public static SSLConfig sslConfig()
public SSLConfig and()
public SSLConfig with()
public SSLConfig using()
public Object getPathToKeyStore()
public String getPassword()
public String getKeyStoreType()
public int getPort()
public KeyStore getTrustStore()
public org.apache.http.conn.ssl.SSLSocketFactory getSSLSocketFactory()
public org.apache.http.conn.ssl.X509HostnameVerifier getX509HostnameVerifier()
public boolean isUserConfigured()
true
if user has configured this SSL Configuration instance, false
otherwise.Copyright © 2010–2014. All rights reserved.