Skip to content

Commit

Permalink
Fix testcert generation by using -e flag to echo.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Mar 11, 2024
1 parent 4080b92 commit 869ec71
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions makefile.certs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
all: cmd/keymaster/testcerts_test.go cmd/keymasterd/testcerts_test.go lib/vip/testcerts_test.go lib/authutil/testcerts_test.go lib/pwauth/ldap/testcerts_test.go lib/client/twofa/testcerts_test.go

lib/client/twofa/testcerts_test.go:
echo "package twofa\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/client/twofa/testcerts_test.go
echo -e "package twofa\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/client/twofa/testcerts_test.go

lib/pwauth/ldap/testcerts_test.go:
echo "package ldap\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/pwauth/ldap/testcerts_test.go
echo -e "package ldap\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/pwauth/ldap/testcerts_test.go

lib/authutil/testcerts_test.go:
echo "package authutil\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/authutil/testcerts_test.go
echo -e "package authutil\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/authutil/testcerts_test.go

lib/vip/testcerts_test.go:
echo "package vip\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/vip/testcerts_test.go
echo -e "package vip\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > lib/vip/testcerts_test.go

cmd/keymasterd/testcerts_test.go: misc/testcerts/localhost.pem misc/testcerts/root.pem misc/testcerts/eekey.pem
echo "package main\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > cmd/keymasterd/testcerts_test.go
echo -e "package main\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > cmd/keymasterd/testcerts_test.go


cmd/keymaster/testcerts_test.go: misc/testcerts/localhost.pem misc/testcerts/root.pem misc/testcerts/eekey.pem
echo "package main\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > cmd/keymaster/testcerts_test.go
echo -e "package main\n\nconst rootCAPem = \``cat misc/testcerts/root.pem`\`\n\nconst localhostCertPem = \``cat misc/testcerts/localhost.pem`\`\n\nconst localhostKeyPem = \``cat misc/testcerts/eekey.pem`\`\n\n" > cmd/keymaster/testcerts_test.go

misc/testcerts/localhost.pem: misc/testcerts/localhost.csr misc/testcerts/localhost.ext misc/testcerts/root.pem
openssl x509 -req -sha256 -days 730 -CAkey misc/testcerts/rootkey.pem -CA misc/testcerts/root.pem -set_serial 12312389324 -out misc/testcerts/localhost.pem -in misc/testcerts/localhost.csr -extfile misc/testcerts/localhost.ext
Expand All @@ -30,7 +30,7 @@ misc/testcerts/localhost.csr: misc/testcerts/eekey.pem
openssl req -new -key misc/testcerts/eekey.pem -batch -out misc/testcerts/localhost.csr -utf8 -subj '/CN=localhost'

misc/testcerts/localhost.ext:
echo "basicConstraints = CA:FALSE\nsubjectAltName =DNS:localhost\nextendedKeyUsage =serverAuth\n" > misc/testcerts/localhost.ext
echo -e "basicConstraints = CA:FALSE\nsubjectAltName =DNS:localhost\nextendedKeyUsage =serverAuth\n" > misc/testcerts/localhost.ext

misc/testcerts/eekey.pem:
openssl genpkey -algorithm RSA -out misc/testcerts/eekey.pem -pkeyopt rsa_keygen_bits:2048
Expand All @@ -42,7 +42,7 @@ misc/testcerts/root.csr: misc/testcerts/rootkey.pem
openssl req -new -key misc/testcerts/rootkey.pem -out misc/testcerts/root.csr -utf8 -subj '/C=US/O=TestOrg/OU=Test CA'

misc/testcerts/root.ext:
echo "basicConstraints = CA:TRUE\n" > misc/testcerts/root.ext
echo -e "basicConstraints = CA:TRUE\n" > misc/testcerts/root.ext

misc/testcerts/rootkey.pem:
openssl genpkey -algorithm RSA -out misc/testcerts/rootkey.pem -pkeyopt rsa_keygen_bits:4096
Expand Down

0 comments on commit 869ec71

Please sign in to comment.