Skip to content

Commit 6444dfc

Browse files
authored
Merge pull request #472 from srvrco/pre-2.15
Update templates to ACMEv2 endpoints
2 parents a5313f4 + 2dbaf3e commit 6444dfc

5 files changed

Lines changed: 37 additions & 19 deletions

File tree

getssl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@
193193
# 2019-11-22 #456 Fix shellcheck issues
194194
# 2019-11-23 #459 Fix missing chain.crt
195195
# 2019-12-18 #462 Use POST-as-GET for ACMEv2 endpoints
196-
# 2020-01-07 #464 and #486 "json was blank" (change all curl request to use POST-as-GET) (2.15)
196+
# 2020-01-07 #464 and #486 "json was blank" (change all curl request to use POST-as-GET)
197+
# 2020-01-08 Error and exit if rate limited, exit if curl returns nothing
198+
# 2020-01-10 Change domain and getssl templates to v2 (2.15)
197199
# ----------------------------------------------------------------------------------------
198200

199201
PROGNAME=${0##*/}
@@ -212,7 +214,7 @@ CODE_LOCATION="https://raw.githubusercontent.com/srvrco/getssl/master/getssl"
212214
CSR_SUBJECT="/"
213215
CURL_USERAGENT="${PROGNAME}/${VERSION}"
214216
DEACTIVATE_AUTH="false"
215-
DEFAULT_REVOKE_CA="https://acme-v01.api.letsencrypt.org"
217+
DEFAULT_REVOKE_CA="https://acme-v02.api.letsencrypt.org"
216218
DNS_EXTRA_WAIT=""
217219
DNS_WAIT=10
218220
DOMAIN_KEY_LENGTH=4096
@@ -1566,7 +1568,7 @@ write_domain_template() { # write out a template file for a domain.
15661568
# The staging server is best for testing
15671569
#CA="https://acme-staging-v02.api.letsencrypt.org/directory"
15681570
# This server issues full certificates, however has rate limits
1569-
#CA="https://acme-v01.api.letsencrypt.org"
1571+
#CA="https://acme-v02.api.letsencrypt.org"
15701572
15711573
#PRIVATE_KEY_ALG="rsa"
15721574
@@ -1619,7 +1621,7 @@ write_getssl_template() { # write out the main template file
16191621
# The staging server is best for testing (hence set as default)
16201622
CA="https://acme-staging-v02.api.letsencrypt.org/directory"
16211623
# This server issues full certificates, however has rate limits
1622-
#CA="https://acme-v01.api.letsencrypt.org"
1624+
#CA="https://acme-v02.api.letsencrypt.org"
16231625
16241626
#AGREEMENT="$AGREEMENT"
16251627
@@ -2021,7 +2023,7 @@ if [[ -s "$CERT_FILE" ]]; then
20212023
enddate_s=$(date_epoc "$enddate")
20222024
if [[ $(date_renew) -lt "$enddate_s" ]] && [[ $_FORCE_RENEW -ne 1 ]]; then
20232025
issuer=$(openssl x509 -in "$CERT_FILE" -noout -issuer 2>/dev/null)
2024-
if [[ "$issuer" == *"Fake LE Intermediate"* ]] && [[ "$CA" == "https://acme-v01.api.letsencrypt.org" ]]; then
2026+
if [[ "$issuer" == *"Fake LE Intermediate"* ]] && [[ "$CA" == "https://acme-v02.api.letsencrypt.org" ]]; then
20252027
debug "upgrading from fake cert to real"
20262028
else
20272029
info "${DOMAIN}: certificate is valid for more than $RENEW_ALLOW days (until $enddate)"

test/Dockerfile-rhel6

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,3 @@ EXPOSE 80 443
2020

2121
# Run eternal loop - for testing
2222
CMD ["/bin/bash", "-c", "while :; do sleep 10; done"]
23-
24-
# with Pebble
25-
# docker-compose -f "docker-compose.yml" up -d --build
26-
# docker exec -it getssl /bin/bash
27-
# /getssl/test/run-test.sh

test/Dockerfile-ubuntu

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,3 @@ EXPOSE 80 443
2121

2222
# Run eternal loop - for testing
2323
CMD ["/bin/bash", "-c", "while :; do sleep 10; done"]
24-
25-
# with Pebble
26-
# docker-compose -f "docker-compose.yml" up -d --build
27-
# docker exec -it getssl /bin/bash
28-
# /getssl/test/run-test.sh

test/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Testing
2+
3+
This directory contains a simple test script which tests creating certificates with Pebble (testing version of the LetsEncrypt server)
4+
5+
Start up pebble, the challdnstest server for DNS challenges
6+
`docker-compose -f "docker-compose.yml" up -d --build`
7+
8+
Run the tests
9+
`docker exec -it getssl /getssl/test/run-test.sh`
10+
11+
Debug (need to set CURL_CA_BUNDLE as pebble uses a local certificate, otherwise you get a "unknown API version" error)
12+
`docker exec -it getssl /bin/bash`
13+
`export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt`
14+
`/getssl/getssl -d getssl`
15+
16+
# TODO
17+
1. Move to BATS (bash automated testing) instead of run-test.sh
18+
2. Test RHEL6, Debian as well
19+
3. Test SSH, SFTP
20+
4. Test wildcards

test/run-test.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
set -e
44

55
# Test setup
6-
rm -r /root/.getssl
6+
if [[ -d /root/.getssl ]]; then
7+
rm -r /root/.getssl
8+
fi
79

810
wget --no-clobber https://raw.githubusercontent.com/letsencrypt/pebble/master/test/certs/pebble.minica.pem
911
# cat /etc/pki/tls/certs/ca-bundle.crt /root/pebble.minica.pem > /root/pebble-ca-bundle.crt
@@ -24,11 +26,12 @@ cp /getssl/test/test-config/getssl-http01.cfg /root/.getssl/getssl/getssl.cfg
2426
# Test #2 - http-01 forced renewal
2527
echo Test \#2 - http-01 forced renewal
2628

27-
sleep 5 # There's a race condition if renew too soon (authlink returns "valid" instead of "pending")
29+
# There's a race condition if renew too soon (authlink returns "valid" instead of "pending")
30+
echo Sleeping 20s to allow previous validation to expire
31+
sleep 20
2832
/getssl/getssl getssl -f
2933

3034
# Test cleanup
31-
3235
rm -r /root/.getssl
3336

3437
# Test #3 - dns-01 verification
@@ -43,5 +46,8 @@ cp /getssl/test/test-config/getssl-dns01.cfg /root/.getssl/getssl/getssl.cfg
4346
# Test #4 - dns-01 forced renewal
4447
echo Test \#4 - dns-01 forced renewal
4548

46-
sleep 5 # There's a race condition if renew too soon (authlink returns "valid" instead of "pending")
49+
# There's a race condition if renew too soon (authlink returns "valid" instead of "pending")
50+
echo Sleeping 30s to allow previous validation to expire
51+
sleep 30
52+
4753
/getssl/getssl getssl -f

0 commit comments

Comments
 (0)