IotHubSSLContext Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.auth.IotHubSSLContext

public class IotHubSSLContext

A simple wrapper for holding the SSLContext used by all connections from clients in this library to the service.

Constructor Summary

Constructor Description
IotHubSSLContext()

Create a default IotHubSSLContext that trusts the certificates stored in your physical device's Trusted Root Certification Authorities certificate store. This IotHubSSLContext can be used for connections that use symmetric key authentication, but cannot be used for connections that use x509 authentication.

IotHubSSLContext(SSLContext sslContext)

Create an IotHubSSLContext that will use the provided sslContext rather than create one based on your device's Trusted Root Certification Authorities certificate store.

Method Summary

Modifier and Type Method and Description
SSLContext getSSLContext()

Get the SSLContext that will be used during the TLS handshake when establishing a connection to the service.

SSLContext getSSLContextFromFile(String trustedCertificatesFilePath)

Create an IotHubSSLContext that trusts the PEM formatted certificates stored in a file with the provided path.

SSLContext getSSLContextFromString(String trustedCertificates)

Create an IotHubSSLContext that trusts the PEM formatted certificates stored in the provided trustedCertificates.

Constructor Details

IotHubSSLContext

public IotHubSSLContext()

Create a default IotHubSSLContext that trusts the certificates stored in your physical device's Trusted Root Certification Authorities certificate store. This IotHubSSLContext can be used for connections that use symmetric key authentication, but cannot be used for connections that use x509 authentication.

IotHubSSLContext

public IotHubSSLContext(SSLContext sslContext)

Create an IotHubSSLContext that will use the provided sslContext rather than create one based on your device's Trusted Root Certification Authorities certificate store.

Parameters:

sslContext - the SSLContext that will be used during the TLS handshake when establishing a connection to the service.

Method Details

getSSLContext

public SSLContext getSSLContext()

Get the SSLContext that will be used during the TLS handshake when establishing a connection to the service.

Returns:

the SSLContext that will be used during the TLS handshake when establishing a connection to the service.

getSSLContextFromFile

public static SSLContext getSSLContextFromFile(String trustedCertificatesFilePath)

Create an IotHubSSLContext that trusts the PEM formatted certificates stored in a file with the provided path.

Parameters:

trustedCertificatesFilePath - the absolute file path of the file that contains the PEM formatted certificates that this IotHubSSLContext will trust.

Returns:

the created IotHubSSLContext.

Throws:

CertificateException - if the provided trustedCertificates are not PEM formatted and cannot be parsed.
IOException - if the provided trustedCertificates cannot be read as a stream.
KeyStoreException - if a key store cannot be created.
NoSuchAlgorithmException - if your device cannot use x509 certificates or TLS SSLContexts.
KeyManagementException - if the created SSLContext cannot be initialized.

getSSLContextFromString

public static SSLContext getSSLContextFromString(String trustedCertificates)

Create an IotHubSSLContext that trusts the PEM formatted certificates stored in the provided trustedCertificates.

Parameters:

trustedCertificates - the PEM formatted certificates that this IotHubSSLContext will trust.

Returns:

the created IotHubSSLContext.

Throws:

CertificateException - if the provided trustedCertificates are not PEM formatted and cannot be parsed.
IOException - if the provided trustedCertificates cannot be read as a stream.
KeyStoreException - if a key store cannot be created.
NoSuchAlgorithmException - if your device cannot use x509 certificates or TLS SSLContexts.
KeyManagementException - if the created SSLContext cannot be initialized.

Applies to