mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
removed save registration.json since it does not work properly
This commit is contained in:
parent
1c611cc9b9
commit
f426dbc9cf
1 changed files with 7 additions and 27 deletions
|
@ -71,13 +71,11 @@ func (p *Provider) ObtainCert() (res E.NestedError) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.user.Registration == nil {
|
if p.user.Registration == nil {
|
||||||
if err := p.loadRegistration(); err.HasError() {
|
|
||||||
if err := p.registerACME(); err.HasError() {
|
if err := p.registerACME(); err.HasError() {
|
||||||
b.Add(E.FailWith("register ACME", err))
|
b.Add(E.FailWith("register ACME", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
client := p.client
|
client := p.client
|
||||||
req := certificate.ObtainRequest{
|
req := certificate.ObtainRequest{
|
||||||
|
@ -89,16 +87,18 @@ func (p *Provider) ObtainCert() (res E.NestedError) {
|
||||||
b.Add(err)
|
b.Add(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = p.saveCert(cert)
|
|
||||||
if err.HasError() {
|
if err = p.saveCert(cert); err.HasError() {
|
||||||
b.Add(E.FailWith("save certificate", err))
|
b.Add(E.FailWith("save certificate", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsCert, err := E.Check(tls.X509KeyPair(cert.Certificate, cert.PrivateKey))
|
tlsCert, err := E.Check(tls.X509KeyPair(cert.Certificate, cert.PrivateKey))
|
||||||
if err.HasError() {
|
if err.HasError() {
|
||||||
b.Add(E.FailWith("parse obtained certificate", err))
|
b.Add(E.FailWith("parse obtained certificate", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
expiries, err := getCertExpiries(&tlsCert)
|
expiries, err := getCertExpiries(&tlsCert)
|
||||||
if err.HasError() {
|
if err.HasError() {
|
||||||
b.Add(E.FailWith("get certificate expiry", err))
|
b.Add(E.FailWith("get certificate expiry", err))
|
||||||
|
@ -187,29 +187,9 @@ func (p *Provider) registerACME() E.NestedError {
|
||||||
}
|
}
|
||||||
p.user.Registration = reg
|
p.user.Registration = reg
|
||||||
|
|
||||||
if err := p.saveRegistration(); err.HasError() {
|
|
||||||
logger.Warn(err)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) loadRegistration() E.NestedError {
|
|
||||||
if p.user.Registration != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
reg := ®istration.Resource{}
|
|
||||||
err := U.LoadJson(RegistrationFile, reg)
|
|
||||||
if err.HasError() {
|
|
||||||
return E.FailWith("parse registration file", err)
|
|
||||||
}
|
|
||||||
p.user.Registration = reg
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Provider) saveRegistration() E.NestedError {
|
|
||||||
return U.SaveJson(RegistrationFile, p.user.Registration, 0o600)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Provider) saveCert(cert *certificate.Resource) E.NestedError {
|
func (p *Provider) saveCert(cert *certificate.Resource) E.NestedError {
|
||||||
err := os.WriteFile(p.cfg.KeyPath, cert.PrivateKey, 0o600) // -rw-------
|
err := os.WriteFile(p.cfg.KeyPath, cert.PrivateKey, 0o600) // -rw-------
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue