@@ -32,11 +32,30 @@ function run_certbot_command() {
3232 error_title_ratelimited=" LetsEncrypt rate limit reached!"
3333
3434 # RSA certificate
35- certbot_args=(certonly --nginx $arg_staging $arg_interactive $arg_dry_run
36- --key-path " $SSL_CERT_KEY_PATH_RSA " --domains " $SERVER_FQDN "
37- --fullchain-path " $SSL_CERT_PATH_RSA " --email " $EMAIL_USER_ADDRESS "
38- --rsa-key-size 4096 --cert-name " $SERVER_FQDN " -rsa
39- --chain-path " $SSL_CHAIN_PATH_RSA " )
35+ case " $CERTBOT_AUTH_METHOD " in
36+ " http" )
37+ certbot_args=(certonly --nginx $arg_staging $arg_interactive $arg_dry_run
38+ --key-path " $SSL_CERT_KEY_PATH_RSA " --domains " $SERVER_FQDN "
39+ --fullchain-path " $SSL_CERT_PATH_RSA " --email " $EMAIL_USER_ADDRESS "
40+ --rsa-key-size 4096 --cert-name " $SERVER_FQDN " -rsa
41+ --chain-path " $SSL_CHAIN_PATH_RSA " )
42+ ;;
43+ " ipv64" )
44+ certbot_args=(certonly $arg_staging $arg_interactive $arg_dry_run
45+ --key-path " $SSL_CERT_KEY_PATH_RSA " --domains " $SERVER_FQDN "
46+ --fullchain-path " $SSL_CERT_PATH_RSA " --email " $EMAIL_USER_ADDRESS "
47+ --rsa-key-size 4096 --cert-name " $SERVER_FQDN " -rsa
48+ --chain-path " $SSL_CHAIN_PATH_RSA "
49+ --authenticator dns-ipv64
50+ --dns-ipv64-credentials " credentials.ini"
51+ --dns-ipv64-propagation-seconds 30)
52+ ;;
53+ * )
54+ log " Unsupported AUTH Method $CERTBOT_AUTH_METHOD !" >&2
55+ exit 1
56+ ;;
57+ esac
58+
4059
4160 log " Executing Certbot using arguments: '${certbot_args[@]} '…"
4261
@@ -62,11 +81,29 @@ function run_certbot_command() {
6281 fi
6382
6483 # ECDSA certificate
65- certbot_args=(certonly --nginx $arg_staging $arg_interactive $arg_dry_run
66- --key-path " $SSL_CERT_KEY_PATH_ECDSA " --domains " $SERVER_FQDN "
67- --fullchain-path " $SSL_CERT_PATH_ECDSA " --email " $EMAIL_USER_ADDRESS "
68- --key-type ecdsa --cert-name " $SERVER_FQDN " -ecdsa
69- --chain-path " $SSL_CHAIN_PATH_ECDSA " )
84+ case " $CERTBOT_AUTH_METHOD " in
85+ " http" )
86+ certbot_args=(certonly --nginx $arg_staging $arg_interactive $arg_dry_run
87+ --key-path " $SSL_CERT_KEY_PATH_ECDSA " --domains " $SERVER_FQDN "
88+ --fullchain-path " $SSL_CERT_PATH_ECDSA " --email " $EMAIL_USER_ADDRESS "
89+ --key-type ecdsa --cert-name " $SERVER_FQDN " -ecdsa
90+ --chain-path " $SSL_CHAIN_PATH_ECDSA " )
91+ ;;
92+ " ipv64" )
93+ certbot_args=(certonly $arg_staging $arg_interactive $arg_dry_run
94+ --key-path " $SSL_CERT_KEY_PATH_ECDSA " --domains " $SERVER_FQDN "
95+ --fullchain-path " $SSL_CERT_PATH_ECDSA " --email " $EMAIL_USER_ADDRESS "
96+ --key-type ecdsa --cert-name " $SERVER_FQDN " -ecdsa
97+ --chain-path " $SSL_CHAIN_PATH_ECDSA "
98+ --authenticator dns-ipv64
99+ --dns-ipv64-credentials " credentials.ini"
100+ --dns-ipv64-propagation-seconds 30)
101+ ;;
102+ * )
103+ log " Unsupported AUTH Method $CERTBOT_AUTH_METHOD !" >&2
104+ exit 1
105+ ;;
106+ esac
70107
71108 log " Executing Certbot using arguments: '${certbot_args[@]} '…"
72109
@@ -92,30 +129,30 @@ function run_certbot_command() {
92129 fi
93130
94131 # Force renewal of certificates
95- certbot_args=(renew --force-renewal $arg_staging $arg_interactive $arg_dry_run )
132+ # certbot_args=(renew --force-renewal $arg_staging $arg_interactive $arg_dry_run)
96133
97- log " Executing Certbot using arguments: '${certbot_args[@]} '…"
134+ # log "Executing Certbot using arguments: '${certbot_args[@]}'…"
98135
99- if certbot " ${certbot_args[@]} " | & tee -a $LOGFILE_PATH ; then
100- return 0
101- else
102- # Checking if Certbot reported rate limit error
103- # Let the user decide if they want staging certificates (for testing
104- # purposes for example).
105- error_ratelimited=" $( tail $LOGFILE_PATH | grep ' too many certificates (5) already issued for this exact set of domains in the last 168 hours' ) "
106- if [ -n " $error_ratelimited " ]; then
107- if [ " $UNATTENDED_INSTALL " != true ]; then
108- if whiptail --title " $error_title_ratelimited " --defaultno \
109- --yesno " $error_message_ratelimited $error_message_ratelimited_extra " 16 65 3>&1 1>&2 2>&3 ; then
110- # Recursively call this function
111- run_certbot_command " true"
112- return 0
113- fi
114- else
115- log " $error_message_ratelimited "
116- fi
117- fi
118- fi
136+ # if certbot "${certbot_args[@]}" |& tee -a $LOGFILE_PATH; then
137+ # return 0
138+ # else
139+ # # Checking if Certbot reported rate limit error
140+ # # Let the user decide if they want staging certificates (for testing
141+ # # purposes for example).
142+ # error_ratelimited="$(tail $LOGFILE_PATH | grep 'too many certificates (5) already issued for this exact set of domains in the last 168 hours')"
143+ # if [ -n "$error_ratelimited" ]; then
144+ # if [ "$UNATTENDED_INSTALL" != true ]; then
145+ # if whiptail --title "$error_title_ratelimited" --defaultno \
146+ # --yesno "$error_message_ratelimited $error_message_ratelimited_extra" 16 65 3>&1 1>&2 2>&3; then
147+ # # Recursively call this function
148+ # run_certbot_command "true"
149+ # return 0
150+ # fi
151+ # else
152+ # log "$error_message_ratelimited"
153+ # fi
154+ # fi
155+ # fi
119156}
120157
121158function install_certbot() {
@@ -130,7 +167,27 @@ function install_certbot() {
130167
131168function certbot_step1() {
132169 log " \nStep 1: Installing Certbot packages"
133- packages_to_install=(python3-certbot-nginx certbot ssl-cert)
170+ if [ " $CERTBOT_AUTH_METHOD " = " " ]; then
171+ if [ " $UNATTENDED_INSTALL " = true ]; then
172+ log " Can't continue since this is a non-interactive installation and I'm" \
173+ " missing CERTBOT_AUTH_METHOD!"
174+ exit 1
175+ fi
176+ fi
177+
178+ case " $CERTBOT_AUTH_METHOD " in
179+ " http" )
180+ packages_to_install=(python3-certbot-nginx certbot ssl-cert)
181+ ;;
182+ " ipv64" )
183+ packages_to_install=(git python3-setuptools python3-certbot-nginx certbot ssl-cert)
184+ ;;
185+ * )
186+ log " Unsupported Certbot AUTH method: $CERTBOT_AUTH_METHOD !" >&2
187+ exit 1
188+ ;;
189+ esac
190+
134191 if ! is_dry_run; then
135192 if [ " $UNATTENDED_INSTALL " == true ]; then
136193 log " Trying unattended install for Certbot."
@@ -139,6 +196,19 @@ function certbot_step1() {
139196 else
140197 apt-get install -y " ${packages_to_install[@]} " 2>&1 | tee -a $LOGFILE_PATH
141198 fi
199+ if [ " $CERTBOT_AUTH_METHOD " = " ipv64" ]; then
200+ CERTBOT_PLUGIN_DIR=" ./certbot-dns-ipv64"
201+ if [ -e " $CERTBOT_PLUGIN_DIR " ]; then
202+ log " Deleted contents of '$CERTBOT_PLUGIN_DIR '."
203+ rm -vrf " $CERTBOT_PLUGIN_DIR " 2>&1 | tee -a $LOGFILE_PATH || true
204+ fi
205+ git clone https://github.com/lodzen/certbot-dns-ipv64.git 2>&1 | tee -a $LOGFILE_PATH
206+ cd certbot-dns-ipv64
207+ git checkout fix-dns-zone 2>&1 | tee -a $LOGFILE_PATH
208+ python3 ./setup.py build 2>&1 | tee -a $LOGFILE_PATH
209+ python3 ./setup.py install 2>&1 | tee -a $LOGFILE_PATH
210+ cd ../
211+ fi
142212 else
143213 log " Would have installed '${packages_to_install[@]} ' via APT now."
144214 fi
0 commit comments