test-certs (1502B)
1 #!/bin/sh 2 # Fixtures used by the upstream EAPoL unit tests. 3 set -eu 4 5 openssl genrsa -out unit/cert-ca-key.pem 2048 6 openssl req -x509 -new -nodes -extensions ca_ext \ 7 -config unit/gencerts.cnf \ 8 -subj '/O=International Union of Example Organizations/CN=Certificate issuer guy/emailAddress=ca@mail.example' \ 9 -key unit/cert-ca-key.pem -sha256 -days 10000 -out unit/cert-ca.pem 10 11 for role in server client; do 12 key=unit/cert-$role-key.pem 13 csr=unit/cert-$role.csr 14 cert=unit/cert-$role.pem 15 case $role in server) organization=Foo ;; client) organization=Bar ;; esac 16 openssl genrsa -out "$key" 2048 17 openssl pkcs8 -topk8 -nocrypt -in "$key" -out "unit/cert-$role-key-pkcs8.pem" 18 openssl req -new -extensions cert_ext -config unit/gencerts.cnf \ 19 -subj "/O=$organization Example Organization/CN=$organization Example Organization/emailAddress=$role@mail.example" \ 20 -key "$key" -out "$csr" 21 openssl x509 -req -extensions server_ext -extfile unit/gencerts.cnf \ 22 -in "$csr" -CA unit/cert-ca.pem -CAkey unit/cert-ca-key.pem \ 23 -CAserial unit/cert-ca.srl -CAcreateserial -sha256 -days 10000 -out "$cert" 24 done 25 26 { 27 printf '%s\n' '[Security]' 'EAP-Method=TLS' 'EAP-Identity=abc@example.com' \ 28 'EAP-TLS-CACert=embed:ca_cert' 'EAP-TLS-ClientCert=embed:client_cert' \ 29 'EAP-TLS-ClientKey=embed:client_key' '[@pem@ca_cert]' 30 cat unit/cert-ca.pem 31 printf '%s\n' '[@pem@client_cert]' 32 cat unit/cert-client.pem 33 printf '%s\n' '[@pem@client_key]' 34 cat unit/cert-client-key-pkcs8.pem 35 } > unit/tls-settings.8021x