Skip to content

Commit d0e8790

Browse files
committed
Update PQC demo scripts to take --keystore argument and update cert/key paths
1 parent 55bdcb8 commit d0e8790

File tree

8 files changed

+72
-75
lines changed

8 files changed

+72
-75
lines changed

examples/pqc-demo/README.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ This tutorial showcases the integration of Post-Quantum Cryptography (PQC) in Io
8686
2. Generate root CA keypair and certificate:
8787
8888
```
89-
trustedge certificate -a QS -g MLDSA_44 -o CA.key -x CA.crt -i ca_csr.cnf -da 3651
89+
trustedge certificate -a QS -g MLDSA_44 -o CA.pem -x CA.pem -i ca_csr.cnf -da 3651
9090
```
9191
9292
3. Generate Mosquitto MQTT broker server keypair and certificate, signed by the root CA:
9393
9494
```
95-
trustedge certificate -a QS -g MLDSA_44 -o server.key -x server.crt -i server_csr.cnf -da 3651 -sk CA.key -sc CA.crt
95+
trustedge certificate -a QS -g MLDSA_44 -o server.pem -x server.pem -i server_csr.cnf -da 3651 -sk CA.pem -sc CA.pem
9696
```
9797
9898
4. Verify the Mosquitto MQTT broker server certificate and the root CA certificate:
9999
100100
```
101-
trustedge certificate -pc /etc/digicert/keystore/certs/server.crt
102-
trustedge certificate -pc /etc/digicert/keystore/certs/CA.crt
101+
trustedge certificate -pc /etc/digicert/keystore/certs/server.pem
102+
trustedge certificate -pc /etc/digicert/keystore/certs/CA.pem
103103
```
104104
105105
### Option 2: EST server key generation and certificate issuance
@@ -116,13 +116,14 @@ This tutorial showcases the integration of Post-Quantum Cryptography (PQC) in Io
116116
2. Generate server key and certificate signed by the root CA:
117117
118118
```
119-
./est_server_keygen_mldsa --estc-server-dn <server-name> --estc-server-url <url> --estc-user <user> --estc-password <password>
119+
./est_server_keygen_mldsa.sh --estc-server-dn <server-name> --estc-server-url <url> --estc-user <user> --estc-password <password>
120120
```
121121
122122
3. Verify server certificate:
123123
124124
```
125-
trustedge certificate -pc /etc/digicert/keystore/certs/mldsa_server_keygen.pem
125+
trustedge certificate -pc /etc/digicert/keystore/certs/server.pem
126+
trustedge certificate -pc /etc/digicert/keystore/certs/CA.pem
126127
```
127128
128129
## Step 4: Configure and start the MQTT broker
@@ -141,11 +142,8 @@ This tutorial showcases the integration of Post-Quantum Cryptography (PQC) in Io
141142
142143
3. Launch the MQTT broker with TLS 1.3 and ML-DSA credentials:
143144
144-
> [!NOTE]
145-
> If the key and certificate was issued using the EST backend, use mldsa_server_keygen.pem for the key and certificate
146-
147145
```
148-
./start_broker.sh --cert /etc/digicert/keystore/certs/server.crt --key /etc/digicert/keystore/keys/server.key
146+
./start_broker.sh --keystore /etc/digicert/keystore
149147
```
150148
151149
To start the MQTT broker using a locally built Mosquitto (build instructions provided in Appendix), use the following steps:
@@ -165,9 +163,9 @@ This tutorial showcases the integration of Post-Quantum Cryptography (PQC) in Io
165163
listener 8883 0.0.0.0
166164
allow_anonymous true
167165
protocol mqtt
168-
cafile /etc/digicert/keystore/certs/server.crt
169-
certfile /etc/digicert/keystore/certs/server.crt
170-
keyfile /etc/digicert/keystore/keys/server.key
166+
cafile /etc/digicert/keystore/certs/server.pem
167+
certfile /etc/digicert/keystore/certs/server.pem
168+
keyfile /etc/digicert/keystore/keys/server.pem
171169
```
172170
173171
Start the broker
@@ -192,12 +190,8 @@ This tutorial showcases the integration of Post-Quantum Cryptography (PQC) in Io
192190
193191
2. Subscribe to topic ```pqc/secure/channel```:
194192
195-
> [!NOTE]
196-
> If the key and certificate was issued using the EST backend, use
197-
the EST CA certificate stored in /etc/digicert/keystore/ca - {digest}.pem
198-
199193
```
200-
./consumer.sh --broker mqtt-pqc-broker --port 8883 --ca-cert /etc/digicert/keystore/certs/CA.crt
194+
./consumer.sh --broker mqtt-pqc-broker --port 8883 --keystore /etc/digicert/keystore
201195
```
202196
203197
3. You should see a “Connected” message followed by readiness to receive.
@@ -212,12 +206,8 @@ This tutorial showcases the integration of Post-Quantum Cryptography (PQC) in Io
212206
213207
2. Publish a test message to ```pqc/secure/channel```:
214208
215-
> [!NOTE]
216-
> If the key and certificate was issued using the EST backend, use
217-
the EST CA certificate stored in /etc/digicert/keystore/ca - {digest}.pem
218-
219209
```
220-
./publisher.sh --broker mqtt-pqc-broker --port 8883 --ca-cert /etc/digicert/keystore/certs/CA.crt
210+
./publisher.sh --broker mqtt-pqc-broker --port 8883 --keystore /etc/digicert/keystore
221211
```
222212
223213
## Step 7: Capture and decrypt handshake in Wireshark

examples/pqc-demo/certGeneration.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ rm -rf /etc/digicert/keystore/keys/*.*
33
rm -rf /etc/digicert/keystore/certs/*.*
44

55

6-
trustedge certificate -a QS -g MLDSA_44 -o CA.key -x CA.crt -i ca_csr.cnf -da 3651
7-
trustedge certificate -a QS -g MLDSA_44 -o server.key -x server.crt -i server_csr.cnf -da 3651 -sk CA.key -sc CA.crt
6+
trustedge certificate -a QS -g MLDSA_44 -o CA.pem -x CA.pem -i ca_csr.cnf -da 3651
7+
trustedge certificate -a QS -g MLDSA_44 -o server.pem -x server.pem -i server_csr.cnf -da 3651 -sk CA.pem -sc CA.pem
88

99
echo "All TrustEdge Key and Certificates Generated Successfully."
1010

1111

12-
trustedge certificate -pc /etc/digicert/keystore/certs/server.crt
12+
trustedge certificate -pc /etc/digicert/keystore/certs/server.pem
1313

14-
trustedge certificate -pc /etc/digicert/keystore/certs/CA.crt
14+
trustedge certificate -pc /etc/digicert/keystore/certs/CA.pem

examples/pqc-demo/client_keys.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/pqc-demo/consumer.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
# Set script directory
66
SCRIPT_DIR=$( cd $(dirname $0) ; pwd -P )
77

8+
DEFAULT_CA_FILE="certs/CA.pem"
9+
810
# Show usage
911
function show_usage
1012
{
@@ -13,7 +15,7 @@ function show_usage
1315
echo " --help - Show help options"
1416
echo " --broker <hostname> - Broker to connect to"
1517
echo " --port <port> - Broker port"
16-
echo " --ca-cert <path> - Path to trusted certificate"
18+
echo " --keystore <path> - Path to keystore (picks up $DEFAULT_CA_FILE by default)"
1719
echo ""
1820
if [ -n "$1" ]; then
1921
echo "$1"
@@ -26,7 +28,7 @@ function show_usage
2628

2729
BROKER=
2830
BROKER_PORT=
29-
CA_CERT_FILE=
31+
KEYSTORE_PATH=
3032

3133
# Parse command line arguments
3234
while test $# -gt 0
@@ -49,11 +51,11 @@ do
4951
BROKER_PORT=$2
5052
shift
5153
;;
52-
--ca-cert)
54+
--keystore)
5355
if [ -z "$2" ]; then
54-
show_usage "Missing --ca-cert argument"
56+
show_usage "Missing --keystore argument"
5557
fi
56-
CA_CERT_FILE=$2
58+
KEYSTORE_PATH=$2
5759
shift
5860
;;
5961
*)
@@ -71,14 +73,16 @@ if [ -z "$BROKER_PORT" ]; then
7173
show_usage "Missing --port argument"
7274
fi
7375

74-
if [ -z "$CA_CERT_FILE" ]; then
75-
show_usage "Missing --ca-cert argument"
76+
if [ -z "$KEYSTORE_PATH" ]; then
77+
show_usage "Missing --keystore argument"
7678
fi
7779

80+
export ENABLE_SSL_KEYLOG=1
81+
7882
trustedge mqtt \
7983
--mqtt_servername $BROKER \
8084
--mqtt_port $BROKER_PORT \
8185
--mqtt_client_id trustedge_sub_client \
8286
--mqtt_sub_topic pqc/secure/channel \
83-
--ssl_ca_file $CA_CERT_FILE \
87+
--ssl_ca_file $KEYSTORE_PATH/$DEFAULT_CA_FILE \
8488
--mqtt_transport SSL

examples/pqc-demo/est_server_keygen_mldsa.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ if [ -n "$ESTC_PASSWORD" ]; then
7979
fi
8080

8181
# Clean up any existing keys/certs
82-
rm -f /etc/digicert/keystore/keys/mldsa_server_keygen.*
83-
rm -f /etc/digicert/keystore/certs/mldsa_server_keygen.*
82+
rm -f /etc/digicert/keystore/keys/server.*
83+
rm -f /etc/digicert/keystore/certs/server.*
8484

8585
wget -P /etc/digicert/keystore/ca http://cacerts.digicert.com/DigiCertGlobalRootG2.crt > /dev/null 2>&1
8686
wget -P /etc/digicert/keystore/ca http://cacerts.digicert.com/DigiCertGlobalRootCA.crt > /dev/null 2>&1
@@ -97,7 +97,18 @@ trustedge certificate est \
9797
--estc-authentication-mode BASIC \
9898
--algorithm QS \
9999
--pq-alg MLDSA_44 \
100-
--key-alias mldsa_server_keygen \
100+
--key-alias server \
101101
--csr-conf server_csr.cnf \
102102
--log-level INFO \
103103
$ESTC_CRED_ARG
104+
105+
# Loop through CA directory and find parent CA cert
106+
for file in /etc/digicert/keystore/ca/*; do
107+
if ./openssl.sh verify -partial_chain -CAfile "$file" /etc/digicert/keystore/certs/server.pem > /dev/null 2>&1; then
108+
cp "$file" /etc/digicert/keystore/certs/CA.pem
109+
echo "Parent CA cert: /etc/digicert/keystore/certs/CA.pem"
110+
break
111+
fi
112+
done
113+
114+
echo "Generated server certificate: /etc/digicert/keystore/certs/server.pem"

examples/pqc-demo/mosquitto/mosq.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ allow_anonymous true
66
listener 8883 0.0.0.0
77
allow_anonymous true
88
protocol mqtt
9-
cafile /etc/digicert/keystore/certs/server.crt
10-
certfile /etc/digicert/keystore/certs/server.crt
11-
keyfile /etc/digicert/keystore/keys/server.key
9+
cafile /etc/digicert/keystore/certs/server.pem
10+
certfile /etc/digicert/keystore/certs/server.pem
11+
keyfile /etc/digicert/keystore/keys/server.pem

examples/pqc-demo/publisher.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set -e
55
# Set script directory
66
SCRIPT_DIR=$( cd $(dirname $0) ; pwd -P )
77

8+
DEFAULT_CA_FILE="certs/CA.pem"
9+
810
# Show usage
911
function show_usage
1012
{
@@ -13,7 +15,7 @@ function show_usage
1315
echo " --help - Show help options"
1416
echo " --broker <hostname> - Broker to connect to"
1517
echo " --port <port> - Broker port"
16-
echo " --ca-cert <path> - Path to trusted certificate"
18+
echo " --keystore <path> - Path to keystore (picks up $DEFAULT_CA_FILE by default)"
1719
echo ""
1820
if [ -n "$1" ]; then
1921
echo "$1"
@@ -26,7 +28,7 @@ function show_usage
2628

2729
BROKER=
2830
BROKER_PORT=
29-
CA_CERT_FILE=
31+
KEYSTORE_PATH=
3032

3133
# Parse command line arguments
3234
while test $# -gt 0
@@ -49,11 +51,11 @@ do
4951
BROKER_PORT=$2
5052
shift
5153
;;
52-
--ca-cert)
54+
--keystore)
5355
if [ -z "$2" ]; then
54-
show_usage "Missing --ca-cert argument"
56+
show_usage "Missing --keystore argument"
5557
fi
56-
CA_CERT_FILE=$2
58+
KEYSTORE_PATH=$2
5759
shift
5860
;;
5961
*)
@@ -71,18 +73,20 @@ if [ -z "$BROKER_PORT" ]; then
7173
show_usage "Missing --port argument"
7274
fi
7375

74-
if [ -z "$CA_CERT_FILE" ]; then
75-
show_usage "Missing --ca-cert argument"
76+
if [ -z "$KEYSTORE_PATH" ]; then
77+
show_usage "Missing --keystore argument"
7678
fi
7779

80+
export ENABLE_SSL_KEYLOG=1
81+
7882
trustedge mqtt \
7983
--mqtt_servername $BROKER \
8084
--mqtt_port $BROKER_PORT \
8185
--mqtt_client_id trustedge_pub_client \
8286
--mqtt_pub_topic pqc/secure/channel \
8387
--mqtt_pub_message "Signature Algorithm > MLDSA" \
8488
--mqtt_pub_message "Key Exchange > X25519MLKEM768" \
85-
--ssl_ca_file $CA_CERT_FILE \
89+
--ssl_ca_file $KEYSTORE_PATH/$DEFAULT_CA_FILE \
8690
--mqtt_transport SSL
8791

8892
sleep 2
@@ -93,5 +97,5 @@ trustedge mqtt \
9397
--mqtt_client_id trustedge_pub_client \
9498
--mqtt_pub_topic pqc/secure/channel \
9599
--mqtt_pub_message "Hello from DigiCert TrustEdge PQC over TLS1.3!!" \
96-
--ssl_ca_file $CA_CERT_FILE \
100+
--ssl_ca_file $KEYSTORE_PATH/$DEFAULT_CA_FILE \
97101
--mqtt_transport SSL

examples/pqc-demo/start_broker.sh

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ set -e
55
# Set script directory
66
SCRIPT_DIR=$( cd $(dirname $0) ; pwd -P )
77

8+
DEFAULT_KEY_FILE="keys/server.pem"
9+
DEFAULT_CERT_FILE="certs/server.pem"
10+
811
# Show usage
912
function show_usage
1013
{
1114
echo "Usage: $0 [options]"
1215
echo "Options:"
1316
echo " --help - Show help options"
14-
echo " --cert <path> - Path to server certificate"
15-
echo " --key <path> - Path to server key"
17+
echo " --keystore <path> - Path to keystore (picks up $DEFAULT_CERT_FILE and $DEFAULT_KEY_FILE by default)"
1618
echo ""
1719
if [ -n "$1" ]; then
1820
echo "$1"
@@ -23,8 +25,7 @@ function show_usage
2325
fi
2426
}
2527

26-
CERT_PATH=
27-
KEY_PATH=
28+
KEYSTORE_PATH=
2829

2930
# Parse command line arguments
3031
while test $# -gt 0
@@ -33,18 +34,11 @@ do
3334
--help)
3435
show_usage
3536
;;
36-
--cert)
37-
if [ -z "$2" ]; then
38-
show_usage "Missing --cert argument"
39-
fi
40-
CERT_PATH=$2
41-
shift
42-
;;
43-
--key)
37+
--keystore)
4438
if [ -z "$2" ]; then
45-
show_usage "Missing --key argument"
39+
show_usage "Missing --keystore argument"
4640
fi
47-
KEY_PATH=$2
41+
KEYSTORE_PATH=$2
4842
shift
4943
;;
5044
*)
@@ -54,12 +48,8 @@ do
5448
shift
5549
done
5650

57-
if [ -z "$CERT_PATH" ]; then
58-
show_usage "Missing --cert argument"
59-
fi
60-
61-
if [ -z "$KEY_PATH" ]; then
62-
show_usage "Missing --key argument"
51+
if [ -z "$KEYSTORE_PATH" ]; then
52+
show_usage "Missing --keystore argument"
6353
fi
6454

6555
if [[ "$(uname -m)" == "x86_64" ]]; then
@@ -71,6 +61,9 @@ else
7161
exit -1
7262
fi
7363

64+
CERT_PATH=$KEYSTORE_PATH/$DEFAULT_CERT_FILE
65+
KEY_PATH=$KEYSTORE_PATH/$DEFAULT_KEY_FILE
66+
7467
export OPENSSL_CONF=$SCRIPT_DIR/mosquitto/openssl.cnf
7568
export OPENSSL_MODULES=$SCRIPT_DIR/mosquitto/$PLATFORM_DIR
7669
export LD_LIBRARY_PATH=$SCRIPT_DIR/mosquitto/$PLATFORM_DIR:$LD_LIBRARY_PATH

0 commit comments

Comments
 (0)