Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS MQTT on OSX

In the OSX app here, I can use AWS MQTT with iOS9, but when I try the same with OSX10.11, I get this error:

CFNetwork SSLHandshake failed (-9829)

Error -9828 is defined as

errSSLPeerCertUnknown = -9829, /* unknown certificate */

My OSX info.plist is

<key>NSAppTransportSecurity</key>
    <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSExceptionDomains</key>
            <dict>
                    <key>amazonaws.com</key>
                    <dict>
                            <key>NSExceptionRequiresForwardSecrecy</key>
                            <false/>
                            <key>NSExceptionAllowsInsecureHTTPLoads</key>
                            <true/>
                            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                            <string>TLSv1.0</string>
                            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                            <false/>
                            <key>NSIncludesSubdomains</key>
                            <true/>
                    </dict>
                    <key>amazonaws.com.cn</key>
                    <dict>
                            <key>NSExceptionRequiresForwardSecrecy</key>
                            <false/>
                            <key>NSExceptionAllowsInsecureHTTPLoads</key>
                            <true/>
                            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                            <string>TLSv1.0</string>
                            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                            <false/>
                            <key>NSIncludesSubdomains</key>
                            <true/>
                    </dict>
            </dict>
    </dict>

The p12 (from "openssl pkcs12 -info -in awsiot-identity.p12") is:

MAC Iteration 2048
MAC verified OK
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Certificate bag
Bag Attributes
    localKeyID: 5F 80 DC 6E AB F1 98 6A AA FC 0B 7B 04 F9 0E 66 99 E9 86 4F 
subject=/CN=AWS IoT Certificate
issuer=/OU=Amazon Web Services O=Amazon.com Inc. L=Seattle ST=Washington C=US
-----BEGIN CERTIFICATE-----
MIIDWTCCAkGgAwIBAgIUJQgfGjmoboOQ7eJo+NTRs5wr8KMwDQYJKoZIhvcNAQEL
BQAwTTFLMEkGA1UECwxCQW1hem9uIFdlYiB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9Q6dfAXlvepkHr4
-----END CERTIFICATE-----
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2048
Bag Attributes
    localKeyID: 5F 80 DC 6E AB F1 98 6A AA FC 0B 7B 04 F9 0E 66 99 E9 86 4F 
Key Attributes: <No Attributes>

Why does OSX fail but iOS succeed?

like image 734
Yusuf X Avatar asked Sep 20 '16 05:09

Yusuf X


People also ask

Does AWS support MQTT?

The AWS IoT Device SDKs support MQTT and MQTT over WSS and support the security requirements of client connections. We recommend using the AWS IoT Device SDKs to connect clients to AWS IoT.

Does AWS provide MQTT broker?

The AWS IoT Core MQTT broker and AWS IoT Device SDK are also compliant with the MQTT 3.1. 1 standard, so you can use these features to create an application that uses MQTT 3.1. 1 across your devices and the AWS Cloud. Choose this option to use MQTT 5 features in communication between core devices and client devices.

Does AWS SNS support MQTT?

The SNS ( sns ) action sends the data from an MQTT message as an Amazon Simple Notification Service (Amazon SNS) push notification. You can follow a tutorial that shows you how to create and test a rule with an SNS action.


1 Answers

It is failing because of an SSL handshake issue. It is detecting an invalid certificate.

A similar issue was reported and resolved here, referencing the same error code. That issue was traced to an identity mismatch, due to multiple identities in the p12 file.

In that case, there were two certificates in the p12 files, but the code was only reading the first one.

I suggest dumping the contents of the .p12 file, and confirming the certificates(s). Post them here to review.

like image 92
Rodrigo Murillo Avatar answered Nov 07 '22 06:11

Rodrigo Murillo