(ctx context.Context, acmeAccount *model.WebsiteAcmeAccount)
| 68 | } |
| 69 | |
| 70 | func newWebsiteSSLLegoClient(ctx context.Context, acmeAccount *model.WebsiteAcmeAccount) (*ssl.AcmeClient, error) { |
| 71 | client, err := ssl.NewAcmeClientWithContext(ctx, acmeAccount, getSystemProxy(acmeAccount.UseProxy)) |
| 72 | if err == nil { |
| 73 | return client, nil |
| 74 | } |
| 75 | if !errors.Is(err, ssl.ErrAcmeAccountURLMissing) { |
| 76 | return nil, err |
| 77 | } |
| 78 | |
| 79 | client, err = ssl.NewRegisterClientWithContext(ctx, acmeAccount, getSystemProxy(acmeAccount.UseProxy)) |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | if client.User.GetRegistration() == nil || client.User.GetRegistration().Location == "" { |
| 84 | return nil, ssl.ErrAcmeAccountURLMissing |
| 85 | } |
| 86 | |
| 87 | acmeAccount.URL = client.User.GetRegistration().Location |
| 88 | if acmeAccount.PrivateKey == "" { |
| 89 | return nil, errors.New("private key can not blank") |
| 90 | } |
| 91 | if err := websiteAcmeRepo.Save(*acmeAccount); err != nil { |
| 92 | return nil, err |
| 93 | } |
| 94 | return client, nil |
| 95 | } |
| 96 | |
| 97 | type IWebsiteSSLService interface { |
| 98 | Page(search request.WebsiteSSLSearch) (int64, []response.WebsiteSSLDTO, error) |
no test coverage detected