Skip to content

Commit

Permalink
Merge pull request #473 from noironetworks/fix-certs
Browse files Browse the repository at this point in the history
Update certificates for UTs
  • Loading branch information
tbachman authored Oct 30, 2023
2 parents 4992aad + b31dbb4 commit 1717ee2
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 77 deletions.
14 changes: 14 additions & 0 deletions libopflex/comms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The test directory has certificate and private key files
used for communications library unit tests. These
certificates need to be renewed from time to time. When
the certs have expired, UTs will fail due to SSL not being
able to decrypt messages.

To generate new certificates, run the shell script in this
directory:
<pre><code>$ sh ./create-new-certs.sh noironetworks.com
</code></pre>

You can verify that the certs are valid using:
<pre><code>$ openssl verify -CAfile test/ca.pem test/server.pem
</code></pre>
81 changes: 81 additions & 0 deletions libopflex/comms/create-new-certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#! /bin/bash

if [ "$#" -ne 1 ]
then
echo "Error: No domain name argument provided"
echo "Usage: Provide a domain name as an argument"
exit 1
fi

DOMAIN=$1

# Create root CA & Private key

openssl req -x509 \
-sha256 -days 356 \
-nodes \
-newkey rsa:2048 \
-subj "/CN=${DOMAIN}/C=US/L=San Fransisco" \
-keyout rootCA.key -out test/ca.pem

# Generate Private key

openssl genrsa -out "${DOMAIN}.key" 2048

# Create csf conf

cat > csr.conf <<EOF
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
C = US
ST = California
L = San Fransisco
O = MLopsHub
OU = MlopsHub Dev
CN = ${DOMAIN}
[ req_ext ]
subjectAltName = @alt_names
[ alt_names ]
DNS.1 = ${DOMAIN}
DNS.2 = www.${DOMAIN}
IP.1 = 192.168.1.5
IP.2 = 192.168.1.6
EOF

# create CSR request using private key

openssl req -new -key "${DOMAIN}.key" -out "${DOMAIN}.csr" -config csr.conf

# Create a external config file for the certificate

cat > cert.conf <<EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${DOMAIN}
EOF

# Create SSl with self signed CA

openssl x509 -req \
-in "${DOMAIN}.csr" \
-CA test/ca.pem -CAkey rootCA.key \
-CAcreateserial -out "${DOMAIN}.crt" \
-days 365 \
-sha256 -extfile cert.conf
cat "${DOMAIN}.key" > test/server.pem
cat "${DOMAIN}.crt" >> test/server.pem
48 changes: 19 additions & 29 deletions libopflex/comms/test/ca.pem
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIFazCCA1OgAwIBAgIUAo0EiiJOHRX1kWmBTSIUJantQqYwDQYJKoZIhvcNAQEL
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMjA0MjYwMTEzMjVaFw0yNTAy
MTMwMTEzMjVaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEB
AQUAA4ICDwAwggIKAoICAQDUT7JveKjKcVH9i+nbmFpqaUvaInrpWhGDE8WBUrK2
u5KGzzOivBNcPqgTtprFRpDNbl51dZ/Hke+/rWACDGp8QbHErr3YJ2NBOfC4/q2r
UofscaRF0De+IAYRoeRbtQYb+ZXVdFd+L3xt4fxXaN6oQkziQftoeVQG8gzowA5q
K8gw4gWuBgzgRMlv/eeGIF/TMqbTJxCF3U5Desyhf6mkVyBCdrGsBoPEzM0W/NWJ
pnMit2IjMGZxqR9lNLGzMTLFaQml0Wz+naiPN8XPBHQxh60NxTEZaiuZKSuMhhmf
XcEbNihOsspxG3k0obNx0cZcIO6XBFnr15Qaro6uoyVV2VJkmBaSdYoHCDbz5OXt
U2O/+KgUanaPssX3leTaKdOc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IiBBLlicRWTc/5Ccar4z1ydow1559uN7FDMq552sVA9Us
BfSXQVVDUVyuXQ7LcRGhJsp/xyZSbotxUOmF89Que+BIyRhUO/2bXa1R+p4Lq05h
tlzlN3YSr6BrP4ydfCLQVcZCthIl/ce3Kvx2TS2h41EEhWrcN+Z2k3oF9aMeV5k5
X928/kak3A==
-----END CERTIFICATE-----
93 changes: 45 additions & 48 deletions libopflex/comms/test/server.pem
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAq2LTCkGB2YGR0c2qsjpdGrWi/hT5Bt/2Hm9z982DxDK3XHaf
xzG+ONGR81AqvCLVA8bMguDJOt4Cc4LrNf3W4e29xnqqEInpJYKzPQHaZJLh6D7t
airs08lYa1rHTEb3rUgPEm1jp6Hfw0bPbreKw0G564IkIdHB9/bRC3y+cD5eY8eU
oRMTDUL89XulH7LTBfMG4NQvgDpB5RNqnXkybLft20stUG4916usw+DXhyFgOA/c
5DTqPohfnjDtrPDLXEDRAmW4fRg3C78SPhJgr2VEmJzPWceIhrLCzuqlGkzaQ7PB
ZDGY69T6nxtQqVTZzv6POuaVMlFqz0w7SF6l9wIDAQABAoIBABLplOBM2kdmRPEi
APQp/Jw17waayeA4VrCFHAb8Zs3/yrwpWvhgRN2AQtrWveCE93yzM1497/bPCPY2
PD55BH1p/scoQhwRG+lHwv+4dKEklElMqGZO1lOIpHk0S0nfivVUPlWKPLUC5+5k
of9VwbpKRnn2ooYY3469bdQWr+0yxmZYQIK27sAmCpfc68qROSezWpmt2xofKdk9
pbKVtdWN1z7zLUjf1aUyDAiM8xKHquOWAM84T9qHNX1b0deuHDOOpIXI7bOk70ft
VS10x6F+8Yi+3bf921FBCl3M6tijEwQFTaUWuuTiMYAcd2PuzWtllqsoFnhjmFy1
5E01igECgYEA3tnmPXXppQohJJWUb52IQ0TK7cKM6GwV8WAdtbsaTE7123+VX22U
Cb0jcZr8OQGTy1RyZNAQEt+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