@@ -35,34 +35,38 @@ if [ "${success}" = "0" ]; then
3535 exit 1
3636fi
3737
38- # # SMTP also has the same cert
39- echo | openssl s_client -showcerts -servername zulip.example.net -connect localhost:25 -starttls smtp \
40- | openssl x509 -text -noout \
41- | tee cert.pem
42- if ! grep -E " Issuer: CN\s*=\s*Pebble Intermediate CA" cert.pem; then
38+ # # SMTP should also have the same cert
39+ # We may need to retry a few times, since nginx gets reloaded first,
40+ # and the email server doesn't go hot-reloads.
41+ success=0
42+ for _ in {1..10}; do
43+ set +o pipefail
44+ echo | openssl s_client -showcerts -servername zulip.example.net -connect localhost:2525 -starttls smtp \
45+ | openssl x509 -text -noout \
46+ | tee cert.pem
47+ set -o pipefail
48+ if grep -E " Issuer: CN\s*=\s*Pebble Intermediate CA" cert.pem; then
49+ success=1
50+ break
51+ fi
52+ sleep 1
53+ done
54+
55+ if [ " ${success} " = " 0" ]; then
4356 echo " SMTP STARTTLS does not have Pebble-signed certificate!"
4457 exit 1
4558fi
4659
4760# # Test renewing -- this should generate and deploy a new certificate
4861serial=$( grep " Serial Number:" cert.pem)
49- " ${docker[@]:? } " exec zulip /usr/bin/certbot renew --force-renew --non-interactive --debug
62+ " ${docker[@]:? } " exec zulip /usr/bin/certbot renew --force-renew --no-random-sleep-on-renew
63+ " ${docker[@]:? } " exec zulip cat /var/log/letsencrypt/letsencrypt.log
5064getcert | tee cert.pem
5165newserial=$( grep " Serial Number:" cert.pem)
5266if [ " ${newserial} " = " ${serial} " ]; then
5367 echo " Failed to renew -- same serial number?"
5468 exit 1
5569fi
56-
57- echo | openssl s_client -showcerts -servername zulip.example.net -connect localhost:25 -starttls smtp \
58- | openssl x509 -text -noout \
59- | tee cert.pem
60- smtpserial=$( grep " Serial Number:" cert.pem)
61- if [ " ${newserial} " != " ${smtpserial} " ]; then
62- echo " Serial numbers on HTTPS and SMTP STARTTLS differ after renew"
63- exit 1
64- fi
65-
6670# For simplicity below, we update $serial
6771serial=" $newserial "
6872
@@ -102,7 +106,7 @@ if grep -qi pebble cert.pem; then
102106fi
103107
104108# # Even if certbot is renewed in the container, we still serve the configured self-signed cert
105- " ${docker[@]:? } " exec zulip /usr/bin/certbot renew --force-renew --non-interactive
109+ " ${docker[@]:? } " exec zulip /usr/bin/certbot renew --force-renew --no-random-sleep-on-renew
106110getcert | tee cert.pem
107111if grep -qi pebble cert.pem; then
108112 echo " Certificate is from Pebble, not self-signed!"
0 commit comments