letsencrypt::Client method certificateRequest (protected)
<instance of letsencrypt::Client> certificateRequest finalizeURL
Defined in /usr/local/ns/tcl/letsencrypt/letsencrypt-procs.tcl
- Parameters:
- finalizeURL (required)
- Testcases:
- No testcase defined.
Source code: :log "<br>Generating key pair of type ${:key_type} for SSL certificate... " set csrConfFile ${:sslpath}/${:domain}.csr.conf set csrFile ${:sslpath}/${:domain}.csr if {${:key_type} eq "ecdsa"} { set keyFile ${:sslpath}/${:domain}.edcsa.key } else { set keyFile ${:sslpath}/${:domain}.key } # # Repeat max 10 times until certificate was successfully obtained # for {set count 0} {$count < 10} {incr count} { :requireKeyFile $keyFile set :certPrivKey [:readFile $keyFile] lassign [exec openssl version -d] _ openssldir file copy -force [file join $openssldir openssl.cnf] $csrConfFile if {[llength ${:sans}] > 0} { set altNames [lmap alt ${:sans} {set _ DNS:$alt}] :writeFile -append $csrConfFile "\n\[SAN\]\nsubjectAltName=[join $altNames ,]\n" set extensions [list -reqexts SAN -extensions SAN] } else { set extensions {} } ns_log notice [subst {call: openssl req -new -sha256 -outform DER {*}$extensions -subj "/CN=${:domain}" -key $keyFile -config $csrConfFile -out $csrFile}] exec openssl req -new -sha256 -outform DER -passout pass:"" {*}$extensions -subj "/CN=${:domain}" -key $keyFile -config $csrConfFile -out $csrFile 2>@1 set csr [:readFile -binary ${:sslpath}/${:domain}.csr] :log "DONE<br>" :log "Getting the certificate for domain ${:domain}, SANs ${:sans}... " set csr64 [ns_base64urlencode -binary $csr] set payload [subst {{"csr": "$csr64"}}] set httpStatus [:send_signed_request $finalizeURL $payload] :log "request to finalize URL $finalizeURL returned HTTP status $httpStatus<br>" :log [:printHeaders ${:replyHeaders}] if {$httpStatus eq "400"} { :log "Certificate request failed. Generating new RSA key pair... " #ns_log notice "CSR-Request returned 400\n" :log "[:printHeaders ${:replyHeaders}]<br>${:replyText}<br>" break } else { break } } if {$httpStatus == 200} { set finalizeDict [json::json2dict ${:replyText}] set certificateURL [dict get $finalizeDict certificate] set httpStatus [:send_signed_request -nolog $certificateURL ""] :log "request to certificate URL $certificateURL returned HTTP status $httpStatus<br>" :log "[:printHeaders ${:replyHeaders}]<br>${:replyText}<br>" } return $httpStatusXQL Not present: Generic, PostgreSQL, Oracle