Skip to content

Quickstart

Register one device and get its certificate in the sandbox (https://api.pki-dev.solar-on.org). It takes about ten minutes.

  • Your vendor is approved in the sandbox portal (https://portal.pki-dev.solar-on.org) for inverter security modules.
  • From the portal’s API keys page you have the private key you made the CSR with (client.key), the client certificate you downloaded (client.crt), and the key value (slzp_test_…). The key needs the devices.write and certs.issue scopes.
  • A terminal (macOS or Linux) with curl, openssl and jq.
  1. Environment and a helper. Run this in the folder with your key files. The pki function adds the key and the client certificate to every call.

    터미널 창
    # Replace with the values from the portal
    export PKI_API=https://api.pki-dev.solar-on.org
    export PKI_API_KEY=slzp_test_your_key
    # client.key = the private key you made the CSR with, client.crt = the client certificate from the portal
    pki() {
    curl --silent --show-error --fail-with-body \
    --cert client.crt --key client.key \
    -H "Authorization: Bearer $PKI_API_KEY" \
    -H "Content-Type: application/json" "$@"
    }
  2. Check the connection. If you see the key name, vendor and scopes, you are ready. On 401, see Errors.

    터미널 창
    # Check the key and certificate
    pki "$PKI_API/v1/me" | jq .
  3. Register a device. Add one device to the registry. Sending the same values again is not an error.

    터미널 창
    # Device serial (use a new one for each try)
    export DEVICE_SERIAL=SN-0001
    pki -X POST "$PKI_API/v1/devices" \
    -d "{\"devices\":[{\"serial\":\"$DEVICE_SERIAL\",\"deviceType\":\"module\"}]}" \
    | jq '{created, unchanged}'
  4. Device key and CSR. On a real device this happens inside the secure element. Here we do it in the terminal. The curve must be P-256.

    터미널 창
    # On the device: make a private key and a CSR. The private key never leaves the device
    openssl ecparam -name prime256v1 -genkey -noout -out device.key
    openssl req -new -key device.key -subj "/CN=$DEVICE_SERIAL" -out device.csr
  5. Issue. Vendors on automatic issuance get the certificate right away: you see approved and the serial, and the chain is saved to device-chain.pem. Vendors on manual issuance see pending and fetch the result after approval with Get an issuance request.

    터미널 창
    jq -n --arg serial "$DEVICE_SERIAL" --rawfile csr device.csr \
    '{deviceSerial: $serial, csrPem: $csr}' \
    | pki -X POST "$PKI_API/v1/certificates" -d @- > issued.json
    jq -r '.request.status, .certificate.serial' issued.json
    jq -r '.chainPem' issued.json > device-chain.pem
  6. Verify the chain with the sandbox root. device-chain.pem: OK means you are done.

    터미널 창
    # Download the sandbox root from the repository and verify the chain
    curl -sS https://pki-dev.solar-on.org/trust.json \
    | jq -r '.anchors[] | select(.kind == "root") | .pem' > root.pem
    openssl verify -CAfile root.pem -untrusted device-chain.pem device-chain.pem