Set up system- and update-report signing
Table of contents:
Introduction
Bosch IoT Rollouts System Software Updates supports to check the authenticity of received system- and update-reports using certificates. This may be required, if the reports are transmitted via an untrusted Software update app. This guide demonstrates how to leverage this feature in three steps:
Create a certificate chain for signing the reports. Note: If you already have a public key infrastructure, or signing certificate in place, you can skip this step.
Configure the fingerprint of a CA as trust anchor in Bosch IoT Rollouts System Software Updates
Create a signed report and upload it to the backend
Prerequisites
A booked Bosch IoT Rollouts including System Software Update extension service instance on EU-1.
You have OpenSSL and a curl with OpenSSL support installed on your client machine.
On MAC OS X this can be achieved with:
$ brew install curl-openssl$ export PATH=/usr/local/opt/curl/bin:$PATH# Tested with$ openssl --version OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)Set up certificate chain for report signing
Generate root CA key and certificate
# Generate ECC key for root CA$ openssl ecparam -name prime256v1 -genkey -noout -out ca_root.keyNote: The Common Name (CN) shouldn’t be empty.
# Generate root CA$ openssl req -x509 -new -key ca_root.key -sha256 -days 1024 -out ca_root.crtGenerate intermediate CA key, signing request, and certificate
# Generate ECC key for intermediate CA$ openssl ecparam -name prime256v1 -genkey -noout -out ca_intermediate.keyNote: The Common Name (CN) shouldn’t be empty.
# Generate certificate signing request$ openssl req -key ca_intermediate.key -new -sha256 -out ca_intermediate.csrCreate the following configuration file:
# File: domainCA.extauthorityKeyIdentifier=keyid,issuerbasicConstraints=CA:TRUEkeyUsage=keyCertSign,cRLSign,digitalSignatureThen, sign the intermediate CA with the root key:
# Sign intermediate CA certificate signing request with root key to create intermediate CA$ openssl x509 -req -in ca_intermediate.csr -CA ca_root.crt -CAkey ca_root.key -CAcreateserial -out ca_intermediate.crt -days 356 -sha256 -extfile domainCA.extGenerated gateway key, signing request, and certificate
# Generate ECC key for gateway certificate$ openssl ecparam -name prime256v1 -genkey -noout -out gateway.keyNote: The Common Name (CN) shouldn’t be empty.
# Generate certificate signing request$ openssl req -key gateway.key -new -out gateway.csrThen, sign the gateway client certificate:
# Generate certificate signing request$ openssl x509 -req -CA ca_intermediate.crt -days 365 -CAkey ca_intermediate.key -in gateway.csr -out gateway.crtCreate certificate chain
For checking the authenticity, the gateway needs to send the entire certificate chain along with the request. Bosch IoT Rollouts System Software Update extension will then validate the certificate chain and extract the fingerprints from all certificates.
To assemble the certificate chain, you can concatenate the single .crt files:
$ cat ca_intermediate.crt ca_root.crt > cert-chain.crtConfigure fingerprint of root CA as trust anchor
The fingerprint is required on the backend side as a trust anchor. The trust anchor can be any CA in the certificate chain depending on your public key infrastructure (PKI) setup. In this example we use the root CA, therefore, the backend trusts all reports signed with any of the certificates in that PKI.
$ openssl x509 -noout -fingerprint -sha256 -inform pem -in ca_root.crtsha256 Fingerprint=BB:EA:2A:13:C7:21:DB:E0:01:37:07:58:5B:ED:85:09:47:D7:FF:8F:BF:9E:E4:65:9C:C3:BA:14:E3:7C:DD:D6Then, configure as trust anchor by setting the fingerprint in the tenant configuration.
Note: If you already have fingerprints configured, you need to add them to the value array otherwise they will be overwritten.
$ curl -X 'POST' \ 'https://system-management.eu1.bosch-iot-rollouts.com/api/mgmt/v1/tenant-config/soup.report.validation.trusted.cert.fingerprints' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer 'eyJhbGciOiJSUzI1NiIsImtpZCI6InB1Y....'' \ -d '{"value": ["BB:EA:2A:13:C7:21:DB:E0:01:37:07:58:5B:ED:85:09:47:D7:FF:8F:BF:9E:E4:65:9C:C3:BA:14:E3:7C:DD:D6"]}'Sign report and upload to Install API
Create signed system reports
After certificates are generated and the fingerprint is configured as trust anchor in Bosch IoT Rollouts System Software Update, the gateway certificate can be used to create signed reports. As input you can use any valid system report.
Note: The same command can be used to create a signed update-report, by adapting the -in <report.json> parameter.
$ openssl cms -sign -in systemreport.json -out systemreport.msg.signed -signer gateway.crt -inkey gateway.key -certfile cert-chain.crt -textThe signed report will look similar to:
$ cat systemreport.msg.signedMIME-Version: 1.0Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha-256"; boundary="----AF8849423398E29336BDF4A4F7FE84A1"This is an S/MIME signed message------AF8849423398E29336BDF4A4F7FE84A1Content-Type: text/plain{ "timeStamp": "1684201667", "gatewayId": "gateway-123", "values": [ { "type": "myModule", "id": "module-456" }, { "type": "gateway", "id": "gateway-123", } ]}------AF8849423398E29336BDF4A4F7FE84A1Content-Type: application/pkcs7-signature; name="smime.p7s"Content-Transfer-Encoding: base64Content-Disposition: attachment; filename="smime.p7s"MIIGMQYJKoZIhvcNAQcCoIIGIjCCBh4CAQExDTALBglghkgBZQMEAgEwCwYJKoZIhvcNAQcBoIIEdTCCAW4wggEToAMCAQICFFJAGgLUplhzzO8yJDve7nkC1ADPMAoGCCqGSM49BAMCMBcxFTATBgNVBAMMDElOVEVSTUVESUFURTAeFw0yNDA1MTAwNzQwMzVaFw0yNTA1MTAwNzQwMzVaMBIxEDAOBgNVBAMMB0dBVEVXQVkwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASga7WCJ62c+yTty9sbzBVKaxCVqMT+/vvZ3jVDSxmr/5uUYeeCK22RqY0z8v10HwmxZCxzLRQdO4npJZBarosXo0IwQDAdBgNVHQ4EFgQUWFL1MzYIYMl5GqNOosodAPig+kYwHwYDVR0jBBgwFoAUuFULx7oc1UVSAsiNjN7UrBFc688wCgYIKoZIzj0EAwIDSQAwRgIhALsoPMnx/OLBMmy9TRuGhHWA4tNmgnSuqEuGrBz/DnAMAiEA+b6WgFUKIliqeBvm7hpJCm3NCT+Fjf7iB0QFu2Sq7XUwggF4MIIBH6ADAgECAgIQATAKBggqhkjOPQQDAjAPMQ0wCwYDVQQDDARST09UMB4XDTI0MDUxMDA3NDAzNVoXDTM0MDUxMTA3NDAzNVowFzEVMBMGA1UEAwwMSU5URVJNRURJQVRFMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAElOMiZDh0VZ3K2Gx/BBWeVi1sQOvuoJt3wnU38DCtiP9aOjoixfFKMQb5Ej04VIyy+hdHJrqsIjyzWj5n8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wQBFjALBglghkgBZQMEAQIwCgYIKoZIhvcNAwcwDgYIKoZIhvcNAwICAgCAMA0GCCqGSIb3DQMCAgFAMAcGBSsOAwIHMA0GCCqGSIb3DQMCAgEoMAoGCCqGSM49BAMCBEgwRgIhALzQXG+Vy2bVckAz4G0vCU5tBPlpBhHBY8tmNqVd+vwqAiEAj/9eR3kRfalw62sHY6wJKg1cy+7LhExisLFASjH/pZU=------AF8849423398E29336BDF4A4F7FE84A1--Upload signed system report
Finally, the signed report can be uploaded using the Install API:
$ curl -X 'POST' \ 'https://system.eu1.bosch-iot-rollouts.com/api/install/v1/system-reports' \ --form 'signedReport=@"./systemreport.msg.signed"' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InB1Y....'