Example program demonstrating use of HTTP or HTTPS protocol over a cellular connection with httpbin.org using the MTSAS library. (Demonstrates GET,POST,basic-auth)
certs.h@6:e5ea200c66c3, 2015-03-16 (annotated)
- Committer:
- Vanger
- Date:
- Mon Mar 16 21:35:01 2015 +0000
- Revision:
- 6:e5ea200c66c3
- Child:
- 7:c477f2ab9624
Added example code for HTTPS connections. (Trusted certificates are stored in certs.h)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vanger | 6:e5ea200c66c3 | 1 | /** Any non-root certificates will have no effect on the SSL client, but will |
Vanger | 6:e5ea200c66c3 | 2 | * use up extra space for their allocation into the certificate list. |
Vanger | 6:e5ea200c66c3 | 3 | * Methods for obtaining the Root CA certificate(s) for a website: |
Vanger | 6:e5ea200c66c3 | 4 | * 1. Open a browser to the target website using HTTPS. |
Vanger | 6:e5ea200c66c3 | 5 | * (These instructions are for Chrome, but should be similar for other browsers) |
Vanger | 6:e5ea200c66c3 | 6 | * Click on the lock icon at the beginning of the url, select the "connection" tab, |
Vanger | 6:e5ea200c66c3 | 7 | * and click the "certificate information" hyperlink. The browser will open a new window |
Vanger | 6:e5ea200c66c3 | 8 | * labeled "Certificate". Switch to the "Certification Path" tab, click the certificate |
Vanger | 6:e5ea200c66c3 | 9 | * closest to the top of the window, then click "View Certificate". This will open a new |
Vanger | 6:e5ea200c66c3 | 10 | * window labeled "Certificate" again. This time, click on the "Details" tab, then click |
Vanger | 6:e5ea200c66c3 | 11 | * "Copy to File". This will open a "Certificate Export Wizard". Click next, and choose the |
Vanger | 6:e5ea200c66c3 | 12 | * "Base-64 encoded X.509 (.CER)" option, then click next. Choose the name and location where |
Vanger | 6:e5ea200c66c3 | 13 | * you want to save the PEM formatted certificate, then click next, then finish. Open the file |
Vanger | 6:e5ea200c66c3 | 14 | * that was created and copy-paste the certificate into this certs.h file. Format the certificate |
Vanger | 6:e5ea200c66c3 | 15 | * data so that each line begins with " and is appended with \r\n" |
Vanger | 6:e5ea200c66c3 | 16 | * |
Vanger | 6:e5ea200c66c3 | 17 | * 2. Go to https://www.bluessl.com/en/ssltest and enter the website for which you wish to get the root CA |
Vanger | 6:e5ea200c66c3 | 18 | * certificates. Click the [Click here to download the public part of this certificate] button located |
Vanger | 6:e5ea200c66c3 | 19 | * underneath the certificates that label themselves as Root, or Root CA. The root CA certificate should |
Vanger | 6:e5ea200c66c3 | 20 | * self-signed, otherwise it is not the root CA certificate. Take the downloaded file, copy the data |
Vanger | 6:e5ea200c66c3 | 21 | * into this certs.h file, and format the data so that each line begins with " and is appended with \r\n" |
Vanger | 6:e5ea200c66c3 | 22 | * |
Vanger | 6:e5ea200c66c3 | 23 | * 3. Using openssl on linux: (Make sure you have openssl installed.) Run the command: openssl s_client |
Vanger | 6:e5ea200c66c3 | 24 | * -showcerts -connect <host>:<port> </dev/null |
Vanger | 6:e5ea200c66c3 | 25 | * Where <host> is the host name (www.google.com for example), and port is the port on which the connection |
Vanger | 6:e5ea200c66c3 | 26 | * will be made (usually 443). When the connection is made with the remote server, the last certificate(s) |
Vanger | 6:e5ea200c66c3 | 27 | * listed will be the Root CA certificate(s). Merely copy-paste those certificates into this certs.h file |
Vanger | 6:e5ea200c66c3 | 28 | * and format them with each line beginning with " and ending with \r\n" |
Vanger | 6:e5ea200c66c3 | 29 | * |
Vanger | 6:e5ea200c66c3 | 30 | */ |
Vanger | 6:e5ea200c66c3 | 31 | |
Vanger | 6:e5ea200c66c3 | 32 | |
Vanger | 6:e5ea200c66c3 | 33 | //Root Certificates |
Vanger | 6:e5ea200c66c3 | 34 | char CERTIFICATES[1547] = |
Vanger | 6:e5ea200c66c3 | 35 | |
Vanger | 6:e5ea200c66c3 | 36 | //Root certificate Authority for Httpbin.org |
Vanger | 6:e5ea200c66c3 | 37 | "-----BEGIN CERTIFICATE-----\r\n" |
Vanger | 6:e5ea200c66c3 | 38 | "MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU\r\n" |
Vanger | 6:e5ea200c66c3 | 39 | "MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs\r\n" |
Vanger | 6:e5ea200c66c3 | 40 | "IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290\r\n" |
Vanger | 6:e5ea200c66c3 | 41 | "MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux\r\n" |
Vanger | 6:e5ea200c66c3 | 42 | "FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h\r\n" |
Vanger | 6:e5ea200c66c3 | 43 | "bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v\r\n" |
Vanger | 6:e5ea200c66c3 | 44 | "dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt\r\n" |
Vanger | 6:e5ea200c66c3 | 45 | "H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9\r\n" |
Vanger | 6:e5ea200c66c3 | 46 | "uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX\r\n" |
Vanger | 6:e5ea200c66c3 | 47 | "mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX\r\n" |
Vanger | 6:e5ea200c66c3 | 48 | "a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN\r\n" |
Vanger | 6:e5ea200c66c3 | 49 | "E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0\r\n" |
Vanger | 6:e5ea200c66c3 | 50 | "WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD\r\n" |
Vanger | 6:e5ea200c66c3 | 51 | "VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0\r\n" |
Vanger | 6:e5ea200c66c3 | 52 | "Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU\r\n" |
Vanger | 6:e5ea200c66c3 | 53 | "cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx\r\n" |
Vanger | 6:e5ea200c66c3 | 54 | "IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN\r\n" |
Vanger | 6:e5ea200c66c3 | 55 | "AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH\r\n" |
Vanger | 6:e5ea200c66c3 | 56 | "YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5\r\n" |
Vanger | 6:e5ea200c66c3 | 57 | "6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC\r\n" |
Vanger | 6:e5ea200c66c3 | 58 | "Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX\r\n" |
Vanger | 6:e5ea200c66c3 | 59 | "c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a\r\n" |
Vanger | 6:e5ea200c66c3 | 60 | "mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=\r\n" |
Vanger | 6:e5ea200c66c3 | 61 | "-----END CERTIFICATE-----\r\n" |
Vanger | 6:e5ea200c66c3 | 62 | ; |