MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / newWebsiteSSLLegoClient

Function newWebsiteSSLLegoClient

agent/app/service/website_ssl.go:70–95  ·  view source on GitHub ↗
(ctx context.Context, acmeAccount *model.WebsiteAcmeAccount)

Source from the content-addressed store, hash-verified

68}
69
70func 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
97type IWebsiteSSLService interface {
98 Page(search request.WebsiteSSLSearch) (int64, []response.WebsiteSSLDTO, error)

Callers 2

obtainSSLMethod · 0.85
DeleteMethod · 0.85

Calls 4

getSystemProxyFunction · 0.85
IsMethod · 0.80
GetRegistrationMethod · 0.80
SaveMethod · 0.65

Tested by

no test coverage detected