Skip to content

Commit

Permalink
update certificate generation script to support v3 certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
jocover committed Feb 27, 2024
1 parent f7453ca commit 50df393
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main/cert/u2f_genkeys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ if [ \! -e esp32key.pem ]; then
openssl ecparam -genkey -out esp32key.pem -name prime256v1
fi

openssl ecparam -genkey -name prime256v1 -out root_key.pem
openssl req -new -key root_key.pem -out root_key.pem.csr -subj "/C=US/ST=Maine/O=OpenSourceSecurity/OU=Root CA/CN=ROOT CA/[email protected]"
openssl x509 -trustout -req -days 18250 -in root_key.pem.csr -signkey root_key.pem -out root_cert.pem -sha256

openssl ec -in esp32key.pem -outform DER -no_public | tail -c +8 | head -c 32 > u2f_cert_key.bin

openssl req -new -key esp32key.pem -out esp32cert.req -subj "/CN=ESP32 U2F"
openssl x509 -req -in esp32cert.req -signkey esp32key.pem -days 3650 -out esp32cert.pem
openssl req -new -key esp32key.pem -out esp32cert.req -subj "/C=US/ST=Maine/O=OpenSourceSecurity/OU=Authenticator Attestation/CN=ESP32 U2F/[email protected]"
openssl x509 -req -in esp32cert.req -CA root_cert.pem -CAkey root_key.pem -extfile v3.ext -set_serial 01 -days 18250 -out esp32cert.pem -sha256
openssl x509 -in esp32cert.pem -outform der -out u2f_cert.bin

rm esp32cert.req esp32cert.pem
rm root_key.pem.csr esp32cert.req esp32cert.pem
4 changes: 4 additions & 0 deletions main/cert/v3.ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment

0 comments on commit 50df393

Please sign in to comment.