|
SharkSSL™ Embedded SSL/TLS Stack
|
When your device connects to a service, it needs to know that the service is the intended one. This tutorial explains how to establish that trust when you control both the device, acting as a TLS client, and the server. You create a Certificate Authority (CA), issue a server certificate, and install the CA's public certificate in the device.
Use this approach for a private device-to-service deployment. If browsers or third-party clients must trust your server without installing a private CA, plan for a publicly trusted certificate. A device that accepts inbound HTTPS connections has a different certificate provisioning task; see the SharkTrust example.
The CA signs the server's certificate. The device trusts the CA because you provision its public certificate through a trusted process. During the TLS handshake, the device checks the server's certificate against that authority and the expected server name. The server proves that it holds the matching private key.
Keep the CA private key separate from the device firmware and server. The server receives only its own private key and certificate chain. A device that only authenticates the server needs the CA public certificate, not the CA private key or a client identity certificate.
A small sensor message does not imply a small TLS handshake. The server sends certificates, and the device needs buffers and working memory to process them. Certificate size, chain length, enabled algorithms, and connection buffer settings all affect peak memory use.
Measure a full handshake with the certificate chain your service will actually send. Measure again after changing algorithms or certificates. Use build configuration to reduce optional code without removing trust checks.
Elliptic Curve Cryptography (ECC) certificates can reduce public-key and signature size compared with RSA certificates at comparable security levels. Check that your server, device build, and any other clients support the chosen key and signature algorithms. The whole certificate chain matters, including intermediate CA certificates.
For example, the TLS 1.2 suite TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 combines:
These are separate jobs. An ECC certificate does not encrypt the application messages. For TLS 1.3, the cipher suite does not select the certificate type; key agreement and signature algorithms are negotiated separately. See cipher suites.
A dual-certificate server is an optional compatibility design. It is not required just because one client is a browser and another is a device. Choose certificate types and trust authorities based on the clients you must support.
Before you start, obtain:
Run the conversion commands below in the directory containing your test certificates, with the SharkSSL tools available on your executable path. They illustrate file conversion, not CA creation or certificate issuance.
localhost as the server name. A device on another computer needs a reachable server name and a certificate for that name.If the certificate tool offers SharkSSL output, it can perform the binary conversion for you. Otherwise, use the command-line tools. Choose certificate lifetimes together with a renewal and trust-store update plan. A private CA gives you control of issuance and provisioning; it also makes you responsible for protecting the CA and maintaining it.
Install the server certificate, matching private key, and required chain in the test server using its configuration interface. Restart or reload it as that server requires. Note its HTTPS listening port.
If the server itself uses SharkSSL binary identity data, convert the certificate and key with the tool supplied in your package:
Conversion does not make a certificate trusted. A browser will trust a private-CA server only if its trust store contains that CA, the server name matches, and its other certificate checks pass. Install a test CA only in a test environment you control.
Convert the CA's public certificate to a SharkSSL CA list:
Use example programs to select a client that matches your application protocol. For an SMQ client, the endpoint is an HTTPS URL, for example https://your-test-server:9443; the server must also provide the matching SMQ service.
If you need certificate-based client authentication, issue a unique client certificate and private key for each device, install that identity in the client, and configure the server to validate it. This is mutual TLS. Plan device-key provisioning and renewal separately from distributing the shared CA public certificate.
Test rejection as well as acceptance. Connect with the wrong expected server name, then with an unrelated CA list. Neither connection should be accepted for application data. When date checking is enabled, also exercise an expired certificate.
Check DNS resolution, routing, and the server's listening address and port. localhost refers to the machine running the client; on an embedded device it does not refer to your development computer.
Confirm that the client is connecting to the TLS port, not a plain HTTP port. Check for a common TLS version and compatible cipher, key-agreement, and signature settings. For TLS 1.2 with an ECDSA-authenticated suite, the server needs a compatible ECDSA identity.
If the handshake completes but trust is rejected, check the installed CA list, server-supplied intermediate certificates, expected domain name, and validity dates. Correct the certificate or provisioning error before sending application data.