(ctx context.Context, ipAddress string, privKey crypto.Signer)
| 167 | } |
| 168 | |
| 169 | func (c *AcmeClient) ObtainIPSSL(ctx context.Context, ipAddress string, privKey crypto.Signer) (certificate.Resource, error) { |
| 170 | unlockDNSChallenge := c.lockDNSChallenge() |
| 171 | defer unlockDNSChallenge() |
| 172 | |
| 173 | csrTemplate := &x509.CertificateRequest{ |
| 174 | Subject: pkix.Name{ |
| 175 | CommonName: "", |
| 176 | }, |
| 177 | IPAddresses: []net.IP{ |
| 178 | net.ParseIP(ipAddress), |
| 179 | }, |
| 180 | } |
| 181 | csrDER, err := x509.CreateCertificateRequest( |
| 182 | rand.Reader, |
| 183 | csrTemplate, |
| 184 | privKey, |
| 185 | ) |
| 186 | if err != nil { |
| 187 | return certificate.Resource{}, err |
| 188 | } |
| 189 | csr, err := x509.ParseCertificateRequest(csrDER) |
| 190 | if err != nil { |
| 191 | return certificate.Resource{}, err |
| 192 | } |
| 193 | req := certificate.ObtainForCSRRequest{ |
| 194 | CSR: csr, |
| 195 | PrivateKey: privKey, |
| 196 | Profile: "shortlived", |
| 197 | Bundle: true, |
| 198 | } |
| 199 | |
| 200 | var certificates *certificate.Resource |
| 201 | for attempt := 1; attempt <= maxRetryAttempts; attempt++ { |
| 202 | certificates, err = c.Client.Certificate.ObtainForCSR(ctx, req) |
| 203 | if err == nil { |
| 204 | return *certificates, nil |
| 205 | } |
| 206 | |
| 207 | if isHTTP503Error(err) && attempt < maxRetryAttempts { |
| 208 | global.LOG.Warnf("ACME server returned 503 for IP SSL, retrying in %v (attempt %d/%d)", |
| 209 | retryDelayOn503, attempt, maxRetryAttempts) |
| 210 | if err := waitForRetry(ctx, retryDelayOn503); err != nil { |
| 211 | return certificate.Resource{}, err |
| 212 | } |
| 213 | continue |
| 214 | } |
| 215 | |
| 216 | return certificate.Resource{}, err |
| 217 | } |
| 218 | |
| 219 | return certificate.Resource{}, err |
| 220 | } |
| 221 | |
| 222 | func (c *AcmeClient) RevokeSSL(pemSSL []byte) error { |
| 223 | return c.Client.Certificate.Revoke(context.Background(), pemSSL) |
no test coverage detected