Skip to content

Conversation

@rajeev-0
Copy link
Collaborator

@rajeev-0 rajeev-0 commented May 6, 2025

Motivation

Script to generate Mock certificates and keys for testing.
Added OpenSSL-3.5 test to CI test.
Added Mock test with PQ algorithm (MLDSA & SLH-DSA) using OpenSSL-3.5.

@rajeev-0 rajeev-0 force-pushed the add_MockTest_cert_generation branch 3 times, most recently from 359b5dc to 57c3c4b Compare May 8, 2025 12:31
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 8, 2025

@rajeev-0 rajeev-0 marked this pull request as ready for review May 8, 2025 12:36
@rajeev-0 rajeev-0 requested a review from DDvO May 8, 2025 12:37
Copy link
Member

@DDvO DDvO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.
Yet various small improvements.


# This script generates the certificates needed for the CMP server and the signer

if [[ ! -f $mkcert_sh ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a concrete use case for setting mkcert_sh externally?
Otherwise I suggest dropping the guard.

Comment on lines +11 to +35
# sever certificate algorithms
if [ -z "$server_rootca_keyalg" ]; then
server_rootca_keyalg="MLDSA65"
fi
if [ -z "$server_leaf_keyalg" ]; then
server_leaf_keyalg="SLH-DSA-SHAKE-192s"
fi
# rootCACert update test case
if [ -z "$new_rootca_keyalg" ]; then
new_rootca_keyalg="SLH-DSA-SHAKE-192s"
fi

# End-entity certificate algorithms
if [ -z "$signer_rootca_keyalg" ]; then
signer_rootca_keyalg="MLDSA65"
fi
if [ -z "$signer_interca_keyalg" ]; then
signer_interca_keyalg="MLDSA65"
fi
if [ -z "$signer_subinterca_keyalg" ]; then
signer_subinterca_keyalg="MLDSA65"
fi
if [ -z "$signer_leaf_keyalg" ]; then
signer_leaf_keyalg="SLH-DSA-SHAKE-192s"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please introduce and use a couple of script parameters, such that the script can be called

  • for updating the hitherto test credentials with the same classical algorithms as before (RSA)
  • for the given PQ tests with MLDSA65 and SLH-DSA-SHAKE-192s
  • for further ones, like KEM


remove_serverfiles() {
echo "Removing server files"
rm -f server.key server-crt trusted.crt server_root.crt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in a file name, and better use same order as above:

Suggested change
rm -f server.key server-crt trusted.crt server_root.crt
rm -f server_root.crt trusted.crt server.key server.crt


gen_servercert() {
remove_serverfiles
sleep 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why sleep? Please comment or remove.

fi

gen_demoCAfolder
openssl ca -gencrl -keyfile signer_subinterCA-key.pem -cert signer_subinterCA-cert.pem -out signer_subinterCA-crl.pem -crldays 36525 \
Copy link
Member

@DDvO DDvO May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use $DAYS after adding early in the script:

if [ -z "$DAYS" ]; then
    DAYS=36524 # 100 years, with 24 leap years per 100 years until 2400
fi

BTW, the 36525 in mkcert.sh typically means 1 day more than 100 years
because a leap year occurs every 4 years, but not every 100 years, but still every 400 years (i.e., in 2000, in 2400, ...)

"database = ./demoCA/index.txt" "crlnumber = ./demoCA/crlnumber" "default_md = default")
cat signer_leaf-cert.pem signer_subinterCA-cert.pem signer_interCA-cert.pem > signer_chain.pem
cat signer_subinterCA-cert.pem signer_interCA-cert.pem signer_root-cert.pem > signer_fullchain.pem
openssl pkcs12 -export -out signer.p12 -inkey signer_leaf-key.pem -in signer_leaf-cert.pem -certfile signer_fullchain.pem -password pass:12345
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
openssl pkcs12 -export -out signer.p12 -inkey signer_leaf-key.pem -in signer_leaf-cert.pem -certfile signer_fullchain.pem -password pass:12345
openssl pkcs12 -export -out signer.p12 -inkey signer_leaf-key.pem -in signer_leaf-cert.pem -certfile signer_fullchain.pem -password file:12345.txt

Comment on lines +100 to +101
openssl pkey -in new.key -out new_pass_12345.key -aes256 -passout pass:12345
echo "12345" > 12345.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
openssl pkey -in new.key -out new_pass_12345.key -aes256 -passout pass:12345
echo "12345" > 12345.txt
openssl pkey -in new.key -out new_pass_12345.key -aes256 -passout file:12345.txt

new_rootca_keyalg="SLH-DSA-SHAKE-192s"
fi

# End-entity certificate algorithms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# End-entity certificate algorithms
# algorithms for client certificate chain

Comment on lines +155 to +156
gen_servercert
gen_signercert
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gen_servercert
gen_signercert
gen_server_chain
gen_client_chain

@@ -0,0 +1,417 @@
#! /bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mark in the file the part(s) adapted, or was an unchanged copy sufficient?

openssl pkey -in new.key -out new_pass_12345.key -aes256 -passout pass:12345
echo "12345" > 12345.txt
cp new.key signer.key
mv signer_leaf-cert.pem signer_only.crt
Copy link
Member

@DDvO DDvO May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a further signer cert with NULL-DN subject and without a subjectKeyIdentifier,
which will be needed in a new test case on senderKID.
If there is no simple way of using for this case mkcert_sh genee, you can also use:

openssl x509 -new -subj "/" -days $DAYS -extfile <(printf "subjectKeyIdentifier=none") -out signer_no_SKID.crt -key signer.key

@DDvO
Copy link
Member

DDvO commented Sep 22, 2025

Please also add a run of make -f Makefile_v1 test_Mock when build with OpenSSL 3.5 (where all test cases are enabled since all new CMP features are present).

 setup-Mock.sh: add files for rootCaCert test

setup-mock.sh: option to set variables from cli
OpenSSL_versions.yaml: add test_Mock for OpenSSL-3.5 with PQ algorithms

Update OpenSSL_versions.yml

Update OpenSSL_versions.yml
@rajeev-0 rajeev-0 force-pushed the add_MockTest_cert_generation branch from 57c3c4b to ba840da Compare October 8, 2025 12:36
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 8, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants