Skip to content

SSL configuration

jalukse edited this page Nov 13, 2019 · 1 revision

Using SSL pinning with the client (> 1.4)

Using the default ssl context

  • By default the client is set up to trust both demo and live environment ssl certificates

If you ant to specify which ssl certificates to trust, there are multiple options

Method Description
SmartIdClient.useDemoEnvSSLCertificates() uses only demo env ssl certificates
SmartIdClient.useLiveEnvSSLCertificates() uses only live env ssl certificates
SmartIdClient.addTrustedSSLCertificates(String ...sslCertificate) add ssl certificates when SK starts to use new
SmartIdClient.setTrustedSSLCertificates(String ...sslCertificates) set specific ssl certificates to trust
SmartIdClient.loadSslCertificatesFromKeystore(KeyStore keyStore) loads only the certificates in the keystore

Example usages

Using only demo certificates

client = new SmartIdClient(); 
client.setRelyingPartyUUID(RELYING_PARTY_UUID); 
client.setRelyingPartyName(RELYING_PARTY_NAME); 
client.setHostUrl(DEMO_URL); 
client.useDemoEnvSSLCertificates()

Using default context(both demo and live ssl certificates are allowed)

client = new SmartIdClient();
client.setRelyingPartyUUID(RELYING_PARTY_UUID);
client.setRelyingPartyName(RELYING_PARTY_NAME);
client.setHostUrl(HOST_URL);

Loading from keystore

InputStream is = SmartIdIntegrationTest.class.getResourceAsStream("/path_to_keystore_resource");
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(is, "changeit".toCharArray());
client = new SmartIdClient();
client.setRelyingPartyUUID(RELYING_PARTY_UUID);
client.setRelyingPartyName(RELYING_PARTY_NAME);
client.setHostUrl(HOST_URL);
client.loadSslCertificatesFromKeystore(keystore);