Переглянути джерело

Arrange automated tests to not use Let's Encrypt

Mike Ashley 9 роки тому
джерело
коміт
1746afcc3a

+ 4
- 0
roles/common/DESIGN.md Переглянути файл

@@ -16,6 +16,10 @@ Certificates and private keys are backed up using tarsnap.
16 16
 
17 17
 Certificate renewal is done automatically using cron. The cron script must be aware of private key copies and update them as well. Services that depend on new keys must also be bounced. It is up to roles that rely on keys to modify the cron script (preferably using `lineinfile` or something similar) to accomplish this.
18 18
 
19
+### Testing support
20
+
21
+An isolated VM deployed with Vagrant is used for testing. The Let's Encrypt service cannot be used to get keys for it, since it is not bound with DNS. A self-signed wildcard key is therefore used for testing. The wildcard key, certificate, and chain are installed in the same way that Let's Encrypt keys are installed.
22
+
19 23
 ### Alternative approaches
20 24
 
21 25
 Two other approaches were considered.

+ 18
- 18
roles/common/files/wildcard_ca.pem Переглянути файл

@@ -1,20 +1,20 @@
1 1
 -----BEGIN CERTIFICATE-----
2
-MIIDPjCCAiYCCQDcHVzv6JwhEzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJB
3
-VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
4
-cyBQdHkgTHRkMRowGAYDVQQDFBEqLnNvdmVyZWlnbi5sb2NhbDAeFw0xMzExMDIx
5
-OTI4NDlaFw0xNDExMDIxOTI4NDlaMGExCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpT
6
-b21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxGjAY
7
-BgNVBAMUESouc292ZXJlaWduLmxvY2FsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
8
-MIIBCgKCAQEArpXru3ZQKl+OVlBar2yziN5ZiVSbt6QYuJtTUmMAfAtGsPobueyI
9
-6XLG6QcFNCWNqUd3fa15GPYluFA5Ot7bPAoo3UQXJvM9n/tQ2YWPjPgxaV4sCKrI
10
-yw7UF+f2NwtUVdj1wHB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cxQKFpUhFOu0kIVoQ7Sa2n
9
+FPKYDC5aTKE7ajgO4cER44WgtBnEXGs7MHQEJL2tT0ETiDfTqSEhTpsXSzCxl7bo
10
+AZIrw9ntJKvTm4Ot04MXsUqeZyr6gk5XMOilluZWTLzbunigKOJItyM3VBRnLWZi
11
+ScznIkbKLGt2WjGIaENOR4cw+wwzOmH0UVxGtGWo/jklGtBZG8mb+fF8rH6L6VBa
12
+nIYHBGlg8Gy0eK430jMD/y2zqlOzY4gE5/BlwaxEupuzL+jtiYGyr7G1tUksQ49v
13
+UNimlAzUINB6bYnIk0MwpIxB0xECj0nz2wIDAQABMA0GCSqGSIb3DQEBCwUAA4IB
14
+AQCEVVrT1ktgvA3CwuIr+/BWRfILIHyayy3FxIwF8wBymAwQiT/09JuNDsLuI2/t
15
+eOY9BZsaJ9BtGA7dajbwKDX83Z+WXcv2AwxbAhxUnpBCQF0MNT9Vh7ixE0rXbXeg
16
+bvy5D4n1MWTBaPK+MpuEEV5m/dRZOFIgf6AWDCB7QixWm7N2BGjqni5kr2EuqYw8
17
+JqxXXtTDTBA8BKMLxPRER+w39zD8fQouTn1pI8nVba/WdX1NlchzFrex6ByvKWQG
18
+joSPd39d68NNyytwmv5LWOQ2Shsk0d0UV9eoFrctPJh8cL4BPfNS7NQR12u55zn0
19
+NR+SN5v9/7fn+/KF1UZq5Jao
20 20
 -----END CERTIFICATE-----

+ 28
- 27
roles/common/files/wildcard_private.key Переглянути файл

@@ -1,27 +1,28 @@
1
------BEGIN RSA PRIVATE KEY-----
2
-MIIEpAIBAAKCAQEArpXru3ZQKl+OVlBar2yziN5ZiVSbt6QYuJtTUmMAfAtGsPob
3
-ueyI6XLG6QcFNCWNqUd3fa15GPYluFA5Ot7bPAoo3UQXJvM9n/tQ2YWPjPgxaV4s
4
-CKrIyw7UF+f2NwtUVdj1wHB0x7bh9asNv+ZDC5O2ze8dn09CS7Puh13bsVFm1iap
5
-ngrrC6ctethJF67A/mRa7UzqHzesAznkgaWfhDL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18
roles/common/files/wildcard_public_cert.crt Переглянути файл

@@ -1,20 +1,20 @@
1 1
 -----BEGIN CERTIFICATE-----
2
-MIIDPjCCAiYCCQDcHVzv6JwhEzANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJB
3
-VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
4
-cyBQdHkgTHRkMRowGAYDVQQDFBEqLnNvdmVyZWlnbi5sb2NhbDAeFw0xMzExMDIx
5
-OTI4NDlaFw0xNDExMDIxOTI4NDlaMGExCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpT
6
-b21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxGjAY
7
-BgNVBAMUESouc292ZXJlaWduLmxvY2FsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
8
-MIIBCgKCAQEArpXru3ZQKl+OVlBar2yziN5ZiVSbt6QYuJtTUmMAfAtGsPobueyI
9
-6XLG6QcFNCWNqUd3fa15GPYluFA5Ot7bPAoo3UQXJvM9n/tQ2YWPjPgxaV4sCKrI
10
-yw7UF+f2NwtUVdj1wHB0x7bh9asNv+ZDC5O2ze8dn09CS7Puh13bsVFm1iapngrr
11
-C6ctethJF67A/mRa7UzqHzesAznkgaWfhDLyygNX0PzI5ywVAKbgvxUWndPx3oY6
12
-yx5jrfk+opMUUnDu9AqhthTPaKK1s3JXJBOW2R/rlgYokfO7VBDkRv/ty3B1BnmS
13
-xdOV/01f5JJdgfLlR6PNd2FMmMoCesg9YwIDAQABMA0GCSqGSIb3DQEBBQUAA4IB
14
-AQAX5KZYIYcMuHRdsd/EKwee+pzp0irs1dqbNwYJIj3HS8Zx/qd+LET4irQbY72N
15
-9Z2s0UTSngy4axlyItKrn+k26FUnSW80W8GMb/dEIyKg5Vnu+zLKnKj85dGUBSAP
16
-AzhNyqkwiY5BFFy/tvuFBvjxle9vkBNZrmtsh/PktzaW3BN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/t
15
+eOY9BZsaJ9BtGA7dajbwKDX83Z+WXcv2AwxbAhxUnpBCQF0MNT9Vh7ixE0rXbXeg
16
+bvy5D4n1MWTBaPK+MpuEEV5m/dRZOFIgf6AWDCB7QixWm7N2BGjqni5kr2EuqYw8
17
+JqxXXtTDTBA8BKMLxPRER+w39zD8fQouTn1pI8nVba/WdX1NlchzFrex6ByvKWQG
18
+joSPd39d68NNyytwmv5LWOQ2Shsk0d0UV9eoFrctPJh8cL4BPfNS7NQR12u55zn0
19
+NR+SN5v9/7fn+/KF1UZq5Jao
20 20
 -----END CERTIFICATE-----

+ 45
- 1
roles/common/tasks/letsencrypt.yml Переглянути файл

@@ -30,10 +30,54 @@
30 30
 - name: Stop Apache
31 31
   service: name=apache2 state=stopped
32 32
 
33
-- name: Get an SSL certificate for {{ domain }}
33
+- name: Get an SSL certificate for {{ domain }} from Let's Encrypt
34 34
   command: /root/letsencrypt/letsencrypt-auto certonly -c /etc/letsencrypt/cli.conf --domains {{ domain }},{{ subdomains }}
35 35
   args:
36 36
     creates: /etc/letsencrypt/live/{{ domain }}/privkey.pem
37
+  when: ansible_ssh_user != "vagrant"
38
+
39
+### Several steps to install a self-signed wildcard key to support offline testing
40
+
41
+- name: Create live directory for testing keys
42
+  file: dest=/etc/letsencrypt/live/{{ domain }} state=directory
43
+    owner=root group=root mode=755
44
+  when: ansible_ssh_user == "vagrant"
45
+
46
+- name: Copy SSL wildcard private key for testing
47
+  copy: src=wildcard_private.key
48
+    dest=/etc/letsencrypt/live/{{ domain }}/privkey.pem
49
+    owner=root group=ssl-cert mode=640
50
+  when: ansible_ssh_user == "vagrant"
51
+
52
+- name: Copy SSL public certificate into place for testing
53
+  copy: src=wildcard_public_cert.crt
54
+    dest=/etc/letsencrypt/live/{{ domain }}/cert.pem
55
+    group=root owner=root mode=644
56
+  register: certificate
57
+  notify: restart apache
58
+  when: ansible_ssh_user == "vagrant"
59
+
60
+- name: Copy SSL CA combined certificate into place for testing
61
+  copy: src=wildcard_ca.pem
62
+    dest=/etc/letsencrypt/live/{{ domain }}/chain.pem
63
+    group=root owner=root mode=644
64
+  register: ca_certificate
65
+  notify: restart apache
66
+  when: ansible_ssh_user == "vagrant"
67
+
68
+- name: Create a combined SSL cert for testing
69
+  shell: cat /etc/letsencrypt/live/{{ domain }}/cert.pem
70
+    /etc/letsencrypt/live/{{ domain }}/chain.pem >
71
+    /etc/letsencrypt/live/{{ domain }}/fullchain.pem
72
+  when: private_key.changed or certificate.changed or ca_certificate.changed
73
+  when: ansible_ssh_user == "vagrant"
74
+
75
+- name: Set permissions on combined SSL public cert
76
+  file: name=/etc/letsencrypt/live/{{ domain }}/fullchain.pem mode=644
77
+  notify: restart apache
78
+  when: ansible_ssh_user == "vagrant"
79
+
80
+### Back to normal
37 81
 
38 82
 - name: Start Apache
39 83
   service: name=apache2 state=started

Завантаження…
Відмінити
Зберегти