Azure / iotedge

The IoT Edge OSS project
MIT License
1.46k stars 461 forks source link

Weird error in connecting leaf device to edge[Transparent gateway] #3491

Closed amit12cool closed 4 years ago

amit12cool commented 4 years ago

I have set up my edge device on an Ubuntu Virtual Box 18.04. The edge device is running successfully with edgeHub, Agent and customModule. In config.yaml my hostname is set to : 192.168.56.108

My leaf device[Nodejs device code azure sdk] is running on a windows 10 machine.

Now, my leaf device is able to ping the edge device and below is output of that:-

Pinging 192.168.56.108 with 32 bytes of data:
Reply from 192.168.56.108: bytes=32 time<1ms TTL=64
Reply from 192.168.56.108: bytes=32 time=1ms TTL=64
Reply from 192.168.56.108: bytes=32 time<1ms TTL=64
Reply from 192.168.56.108: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.56.108:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

Also the edge open ssl command works too that is the edge and leaf device connection give code 0 -OK. Check below output:-

$ openssl s_client -connect 192.168.56.108:8883 -CAfile azure-iot-test-only.root.ca.cert.pem -showcerts
CONNECTED(00000224)
Can't use SSL_get_servername
depth=4 CN = Azure_IoT_Hub_CA_Cert_Test_Only
verify return:1
depth=3 CN = Azure_IoT_Hub_Intermediate_Cert_Test_Only
verify return:1
depth=2 CN = cacert_test.ca
verify return:1
depth=1 CN = iotedged workload ca
verify return:1
depth=0 CN = 192.168.56.108
verify return:1
---
Certificate chain
 0 s:CN = 192.168.56.108
   i:CN = iotedged workload ca
-----BEGIN CERTIFICATE-----
MIIEczCCAlugAwIBAgIEa4tFZzANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBRp
b3RlZGdlZCB3b3JrbG9hZCBjYTAeFw0yMDA5MDMxMTM1NDVaFw0yMDA5MjMxMDE3
MjJaMBkxFzAVBgNVBAMMDjE5Mi4xNjguNTYuMTA4MIIBIjANBgkqhkiG9w0BAQEF
AAOCAQ8AMIIBCgKCAQEAuTSZBZAer0KZ3PD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fnXMRAozwE+3g3AgMBAAGjgZgwgZUwHQYDVR0OBBYEFKewOce5FdjU
+tQY3G9Isc2TECTGMFMGA1UdIwRMMEqAFFHp02wXhtzqrXiNsx20qss7poS9oS6k
LDAqMSgwJgYDVQQDDB9BenVyZV9Jb1RfSHViX0NBX0NlcnRfVGVzdF9Pbmx5ggIQ
ADAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
AAOCAgEAYWXfIm85u4tyijGKH2YKCJ/2jV6ucEiwMI+4GzgzwNP0ajXUqWqpwOC6
I/W+lkJhiKKoJrR03MycK3C58I5YVnegqbNIhiX411DSHOTzOw/n/HUlzxn8V7WU
VizdxRBLPoOiafFuWruXYXTRcun+NmuTb2czCzYbEyPflwcebLm/UkTDpp/p+w0i
FnraAqzQSXvK543NImLYI0T7vSYbYf9pykgS7LBdHyHsztq65cjzdf3kCDMAerZV
z8WfA/p5cfbOoGFfMlSRdC2Y96iQMH2ylkReeJksgvQ3VbZOz4OZCceywHDoxDHJ
uvg87Rvr5/zMVxSUe0yvZsr0hCy2Mn8YlrhPEhDklL7rq3sLDEL1cgvAoo84QICp
wWD6clSNkjYVjhykzTqzD0bZhUwLCyY+cPq/kDCWrgSBQgN+eZrawPqau/VaJYx2
BJ79QU2bwiWEkSA4JpxDHkzHqKRDNIJwjYuq5a7A2GGDfAS9UxNeeHsLnd6OQs5v
NO6Jd71zavjskniY0xbw6D7VwRvweCWmUipSbuXrm9vweLUbni3TgsY8Y6Cezq1Z
XW6l6RkU1vCVBUPJD9B7SAU5zxvr6KP2guDnspkY51RggD0SKydr4vsObcvctCOa
7z1HeEPWQR9HRczAnvQLBBmdBWpvMcwPY29lV7eJo8qur/F8tbs=
-----END CERTIFICATE-----
 3 s:CN = Azure_IoT_Hub_Intermediate_Cert_Test_Only
   i:CN = Azure_IoT_Hub_CA_Cert_Test_Only
-----BEGIN CERTIFICATE-----
MIIFhTCCA22gAwIBAgICEAAwDQYJ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vVF9IdWJfQ0Ff
Q2VydF9UZXN0X09ubHmCFGXP55Wfwnwxr1lC8mLbMdPs9dxlMA8GA1UdEwEB/wQF
MAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQCq0bhoPXp0
2FKKCrtxNd9uzuPGc1h5tT8+jo08CotVezxB8zwlqgxXosuXWisgIzDGVoyHTtvq
YbrzIKfQLR09l/u37jLD/ZMQ3re7Vavjj5S2O3bmIsLGlERkwjuzSTTmkF2JMaMg
XAQIM9p9jZfcFrZG/v7vjlyagwoZR9WvbNfz3Ixr6ZbjjJRdPphbyDZ9/8gZykvZ
IJaycnJykI+VRBO+j9JZsicDDv7bxtF/dMgMVjOgczd5nIQBgCGcntZ2LzlwDd2g
RFUXrnS6M/tcet9pchkiq936PzQgfjddw9wocjukl9L91U15aL0/lbR57pUtkVyb
Z8BIYRlB1AJVtoURLVzPuFmGihI3YlsLlQBFSwqFvHO7hO9VrIRkxfeBzclsPEar
n+oodT1ez1+nMK5L1NSOQKUDSAm13eif5MQNIiY5vd93qvDMiMhXnjyfqc7RDhgY
3UIK8BikJZhxP1C2yYunkPFMXoCJVL3bduvQVLGf74T+dDr/cepsC+L6xeteMUmB
Ws49+FD+uj+HzOHGFOFYxrgwj1TDqM/hFVmdTOoA/Nn5fc8XX++/OAyR6vsrEjfx
4jyDOoy9Mr/KBbkyxZJ145UPkFb3oRFAwLbCRlyT810HS6qLt6XeBouKIG9HwVwI
ZPJo3YN8mUn2Yb6NtKZHOhOynVoQVWA7QA==
-----END CERTIFICATE-----
---
Server certificate
subject=CN = 192.168.56.108

issuer=CN = iotedged workload ca

---
No client certificate CA names sent
Client Certificate Types: RSA sign, DSA sign, ECDSA sign
Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:ECDSA+SHA1:RSA+SHA224:RSA+SHA1:DSA+SHA224:DSA+SHA1:DSA+SHA256:DSA+SHA384:DSA+SHA512
Shared Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:ECDSA+SHA1:RSA+SHA224:RSA+SHA1:DSA+SHA224:DSA+SHA1:DSA+SHA256:DSA+SHA384:DSA+SHA512
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 6015 bytes and written 398 bytes
Verification: OK
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: AA5C1938774876B2377EFA62F4D5A20DD6AC44BF24786BF1FAD53BBA9E778BA3
    Session-ID-ctx:
    Master-Key: 8D01BAE31801D5F5BF12C128AFDE493D9021AB46AA986D2E950165E21CADF9280C01542401D6C1DA255BF364A3BC7A54
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - c8 b7 7d 7c 24 43 45 ab-fe 1c 28 27 17 63 ec 92   ..}|$CE...('.c..
    0010 - 96 f1 91 cb e7 8b 25 47-c6 9d 6f a2 b8 27 57 a4   ......%G..o..'W.
    0020 - 68 14 7d 5e b3 81 b4 6a-d9 dd 37 a1 82 02 49 c6   h.}^...j..7...I.
    0030 - 75 1f ad 37 93 45 5d 25-5a f6 c6 63 e5 d6 d0 41   u..7.E]%Z..c...A
    0040 - 00 3d 88 f0 fe 2d 70 df-1e f2 8f ed 37 b3 58 5c   .=...-p.....7.X\
    0050 - 1b 85 2d 95 78 77 db f3-41 2e 3b 21 0b 7a af 8d   ..-.xw..A.;!.z..
    0060 - 5d 52 03 58 77 1d 6b 70-47 fd a0 93 b9 94 03 73   ]R.Xw.kpG......s
    0070 - 42 2c a2 31 07 dd f7 8a-87 e3 04 2c 4c 43 b4 e8   B,.1.......,LC..
    0080 - fc 3f 25 3c a0 d0 69 33-20 73 20 e3 f6 4c 42 8b   .?%<..i3 s ..LB.
    0090 - 24 95 70 00 33 08 c0 a7-4f 55 04 de 48 a9 cf 0a   $.p.3...OU..H...

    Start Time: 1599134410
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: yes
---

Now the issue is, when I run my leaf device nodejs code which use MQTT i get the below error in debug mode:-

mqtt-packet:parser _resetState: resetting packet, error, _list, and _stateCounter +187ms
  mqtt-packet:writeToStream generate called +175ms
  mqtt-packet:writeToStream generate: packet.cmd: connect +1ms
  mqtt-packet:writeToStream writeVarByteInt: writing to stream: <Buffer ae 01> +0ms
  mqtt-packet:writeToStream writeNumberCached: number: 4 +1ms
  mqtt-packet:writeToStream writeNumberCached: <Buffer 00 04> +0ms
  mqtt-packet:writeToStream writeString: MQTT +1ms
  mqtt-packet:writeToStream writeNumberCached: number: 180 +0ms
  mqtt-packet:writeToStream writeNumberCached: <Buffer 00 b4> +1ms
  mqtt-packet:writeToStream writeNumberCached: number: 10 +0ms
  mqtt-packet:writeToStream writeNumberCached: <Buffer 00 0a> +1ms
  mqtt-packet:writeToStream writeString: amidhaleaf +0ms
  mqtt-packet:writeToStream writeNumberCached: number: 150 +1ms
  mqtt-packet:writeToStream writeNumberCached: <Buffer 00 96> +0ms
  mqtt-packet:writeToStream writeString: 192.168.56.108/amidhaleaf/?api-version=2019-03-30&DeviceClientType=azure-iot-device%2F1.12.2%20(node%20v10.16.3%3B%20Windows_NT%2010.0.17763%3B%20x64) +1ms
  azure-iot-mqtt-base:MqttBase received 'error' from mqtt client +35ms
  azure-iot-mqtt-base:MqttBase connecting -> disconnected () +1ms
  azure-iot-device-mqtt:Mqtt connect +37ms
  azure-iot-device-mqtt:Mqtt connecting -> disconnected () +0ms
  azure-iot-mqtt-base:translateError translating: Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: IP: 192.168.56.108 is not in the cert's list:  +157ms
  azure-iot-common:RetryOperation Will retry after: 166.71304047503034 milliseconds +157ms

Exact error from above log

  azure-iot-mqtt-base:translateError translating: Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: IP: 192.168.56.108 is not in the cert's list:  +328ms

It seems I'm missing something in certificate. Any help is appreciated.

Note:- Above all works fine if my both leaf device and Edge device are running on the same VIrtualbox machine

amit12cool commented 4 years ago

Ok, So I have resolved this issue. Solution below for those in need

On VirtualBox(Edge device)

1. Firstly I changed the hostname in config.yaml of edge device from ip address to hostname.
    Previous: hostname:  "192.168.56.108"
    Changed: hostname: "myedgedevice"
2. Added entry in /etc/hosts
    192.168.56.108 myedgedevice
On windows machine(leaf device)
1. Added entry in c:\Windows\System32\Drivers\etc\hosts
    192.168.56.108 myedgedevice

Now my leaf device connection string is as below
"HostName=myedgedevice;DeviceId=leafdeviceId;x509=true"

So the solution was to have the /etc/hosts entry in place for both edge and leaf devices