尝试使用自己的x509证书运行azure-iot-sdk-java Provisioning-x509-sample

时间:2018-10-31 09:23:51

标签: azure-iot-hub azure-iot-sdk

我正在尝试运行azure-iot-sdk-java Provisioning-X509-sample。

我要做的是,我已经用openssl创建了一个证书链,并生成了一个X509证书。我将此证书上传到了天蓝色的DPS。 我检查了上传证书的指纹,一切看起来都很好。

在下一步中,我配置ProvisioningX509Sample.java。输入idScope,globalEndpoint并作为leafPublicPem输入Base64字符串

"-----BEGIN CERTIFICATE-----" + "\n" +
************ + "\n" +
"-----END CERTIFICATE-----"

我还输入了我的中间CA的私钥作为leafPrivateKey,该私钥创建/签名了X509设备验证证书

"-----BEGIN RSA PRIVATE KEY-----" + "\n" +
************+ "\n" +
"-----END RSA PRIVATE KEY-----";

作为传输协议,我将使用MQTT

如果运行此示例,则会出现以下错误

Starting...
Beginning setup.
Waiting for Provisioning Service to register
com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceConnectionException: Exception opening connection amqp
        at com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.mqtt.ContractAPIMqtt.open(ContractAPIMqtt.java:142)
        at com.microsoft.azure.sdk.iot.provisioning.device.internal.task.ProvisioningTask.call(ProvisioningTask.java:267)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Unable to connect to mqtt service
        at com.microsoft.azure.sdk.iot.deps.transport.mqtt.MqttConnection.connect(MqttConnection.java:151)
        at com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.mqtt.ContractAPIMqtt.open(ContractAPIMqtt.java:135)
        ... 5 more
Caused by: MqttException (0) - javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:715)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        ... 3 more
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1002)
        at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1779)
        at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124)
        at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:1156)
        at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1267)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1179)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1052)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:987)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
        at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:108)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:701)
        ... 7 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
        at sun.security.ssl.InputRecord.read(InputRecord.java:505)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
        ... 21 more
Registration error, bailing out
Press any key to exit...

我不明白此错误。还有另外一步吗?

感谢您的帮助和问候

JensV

1 个答案:

答案 0 :(得分:0)

DPS仅支持TLS 1.2。旧版本的TLS连接将被拒绝。