in iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/transport/amqps/AmqpsIotHubConnection.java [436:493]
public void onConnectionBound(Event event)
{
Transport transport = event.getTransport();
// Convert from seconds to milliseconds since this proton-j API only accepts keep alive in milliseconds
transport.setIdleTimeout(keepAliveInterval * 1000);
if (this.isWebsocketConnection)
{
addWebSocketLayer(transport);
}
try
{
Iterator<ClientConfiguration> configsIterator = this.clientConfigurations.iterator();
ClientConfiguration defaultConfig = configsIterator.hasNext() ? configsIterator.next() : null;
SSLContext sslContext;
if (defaultConfig != null)
{
sslContext = defaultConfig.getAuthenticationProvider().getSSLContext();
}
else if (this.sslContext != null)
{
// This should only be hit when a user creates a multiplexing client and specifies an SSLContext
// that they want to use
sslContext = this.sslContext;
}
else
{
// This should only be hit when a user creates a multiplexing client and doesn't specify an SSLContext
// that they want to use
sslContext = new IotHubSSLContext().getSSLContext();
}
if (this.authenticationType == ClientConfiguration.AuthType.SAS_TOKEN)
{
Sasl sasl = transport.sasl();
sasl.setMechanisms("ANONYMOUS");
}
SslDomain domain = Proton.sslDomain();
domain.setSslContext(sslContext);
domain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER);
domain.init(SslDomain.Mode.CLIENT);
transport.ssl(domain);
}
catch (IOException e)
{
this.savedException = new TransportException(e);
log.error("Encountered an exception while setting ssl domain for the amqp connection", this.savedException);
}
// Adding proxy layer needs to be done after sending SSL message
if (proxySettings != null)
{
addProxyLayer(transport, event.getConnection().getHostname() + ":" + WEB_SOCKET_PORT);
}
}