Gilles Peskine | f040a17 | 2017-05-05 18:56:12 +0200 | [diff] [blame] | 1 | OPENSSL = openssl |
| 2 | |
| 3 | cli_crt_key_file_rsa = cli-rsa.key |
| 4 | cli_crt_extensions_file = cli.opensslconf |
| 5 | test_ca_key_file_rsa = test-ca.key |
| 6 | test_ca_pwd_rsa = PolarSSLTest |
| 7 | test_ca_config_file = test-ca.opensslconf |
| 8 | |
| 9 | default: all_final |
| 10 | |
| 11 | all_intermediate := # temporary files |
| 12 | all_final := # files used by tests |
| 13 | |
| 14 | test-ca.csr: $(test_ca_key_file_rsa) $(test_ca_config_file) |
| 15 | $(OPENSSL) req -new -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Test CA" -out $@ |
| 16 | all_intermediate += test-ca.csr |
| 17 | test-ca-sha1.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr |
| 18 | $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha1 -in test-ca.csr -out $@ |
| 19 | all_final += test-ca-sha1.crt |
| 20 | test-ca-sha256.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr |
| 21 | $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha256 -in test-ca.csr -out $@ |
| 22 | all_final += test-ca-sha256.crt |
| 23 | |
| 24 | cli-rsa.csr: $(cli_crt_key_file_rsa) |
| 25 | $(OPENSSL) req -new -key $(cli_crt_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Client 2" -out $@ |
| 26 | all_intermediate += cli-rsa.csr |
| 27 | cli-rsa-sha1.crt: $(cli_crt_key_file_rsa) test-ca-sha1.crt cli-rsa.csr |
| 28 | $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha1.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha1 -in cli-rsa.csr -out $@ |
| 29 | all_final += cli-rsa-sha1.crt |
| 30 | cli-rsa-sha256.crt: $(cli_crt_key_file_rsa) test-ca-sha256.crt cli-rsa.csr |
| 31 | $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in cli-rsa.csr -out $@ |
| 32 | all_final += cli-rsa-sha256.crt |
| 33 | |
Gilles Peskine | bc70a18 | 2017-05-09 15:59:24 +0200 | [diff] [blame^] | 34 | server2-rsa.csr: server2.key |
| 35 | $(OPENSSL) req -new -key server2.key -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=localhost" -out $@ |
| 36 | all_intermediate += server2-rsa.csr |
| 37 | server2-sha256.crt: server2-rsa.csr |
| 38 | $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in server2-rsa.csr -out $@ |
| 39 | all_final += server2-sha256.crt |
| 40 | |
| 41 | |
Gilles Peskine | f040a17 | 2017-05-05 18:56:12 +0200 | [diff] [blame] | 42 | all_final: $(all_final) |
| 43 | all: $(all_intermediate) $(all_final) |
| 44 | |
| 45 | # These files should not be committed to the repository. |
| 46 | list_intermediate: |
| 47 | @printf '%s\n' $(all_intermediate) | sort |
| 48 | # These files should be committed to the repository so that the test data is |
| 49 | # available upon checkout without running a randomized process depending on |
| 50 | # third-party tools. |
| 51 | list_final: |
| 52 | @printf '%s\n' $(all_final) | sort |
| 53 | |
| 54 | clean: |
| 55 | rm -f $(all_intermediate) |
| 56 | neat: clean |
| 57 | rm -f $(all_final) |