(ctx context.Context, domains []string, privateKey crypto.Signer)
| 128 | } |
| 129 | |
| 130 | func (c *AcmeClient) ObtainSSL(ctx context.Context, domains []string, privateKey crypto.Signer) (certificate.Resource, error) { |
| 131 | unlockDNSChallenge := c.lockDNSChallenge() |
| 132 | defer unlockDNSChallenge() |
| 133 | |
| 134 | // lego v5 disables Common Name by default; explicitly enable it to keep |
| 135 | // the v4 behaviour, so legacy Java/router clients that still rely on the |
| 136 | // CommonName field do not fail TLS handshake. |
| 137 | request := certificate.ObtainRequest{ |
| 138 | Domains: domains, |
| 139 | Bundle: true, |
| 140 | PrivateKey: privateKey, |
| 141 | EnableCommonName: true, |
| 142 | } |
| 143 | |
| 144 | var certificates *certificate.Resource |
| 145 | var err error |
| 146 | |
| 147 | for attempt := 1; attempt <= maxRetryAttempts; attempt++ { |
| 148 | certificates, err = c.Client.Certificate.Obtain(ctx, request) |
| 149 | if err == nil { |
| 150 | return *certificates, nil |
| 151 | } |
| 152 | |
| 153 | if isHTTP503Error(err) && attempt < maxRetryAttempts { |
| 154 | global.LOG.Warnf("ACME server returned 503, retrying in %v (attempt %d/%d)", |
| 155 | retryDelayOn503, attempt, maxRetryAttempts) |
| 156 | if err := waitForRetry(ctx, retryDelayOn503); err != nil { |
| 157 | return certificate.Resource{}, err |
| 158 | } |
| 159 | continue |
| 160 | } |
| 161 | |
| 162 | // Non-503 error or final attempt, return error |
| 163 | return certificate.Resource{}, err |
| 164 | } |
| 165 | |
| 166 | return certificate.Resource{}, err |
| 167 | } |
| 168 | |
| 169 | func (c *AcmeClient) ObtainIPSSL(ctx context.Context, ipAddress string, privKey crypto.Signer) (certificate.Resource, error) { |
| 170 | unlockDNSChallenge := c.lockDNSChallenge() |
nothing calls this directly
no test coverage detected