Escape path character in certificate scopes
This commit is contained in:
parent
cab23032c0
commit
35e984fbba
4
cert.go
4
cert.go
@ -48,6 +48,8 @@ func (c *CertificateDir) Add(scope string, cert tls.Certificate) {
|
|||||||
// Write writes the provided certificate to the certificate directory.
|
// Write writes the provided certificate to the certificate directory.
|
||||||
func (c *CertificateDir) Write(scope string, cert tls.Certificate) error {
|
func (c *CertificateDir) Write(scope string, cert tls.Certificate) error {
|
||||||
if c.dir {
|
if c.dir {
|
||||||
|
// Escape slash character
|
||||||
|
scope = strings.ReplaceAll(scope, "/", ":")
|
||||||
certPath := filepath.Join(c.path, scope+".crt")
|
certPath := filepath.Join(c.path, scope+".crt")
|
||||||
keyPath := filepath.Join(c.path, scope+".key")
|
keyPath := filepath.Join(c.path, scope+".key")
|
||||||
if err := WriteCertificate(cert, certPath, keyPath); err != nil {
|
if err := WriteCertificate(cert, certPath, keyPath); err != nil {
|
||||||
@ -81,6 +83,8 @@ func (c *CertificateDir) Load(path string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
scope := strings.TrimSuffix(filepath.Base(crtPath), ".crt")
|
scope := strings.TrimSuffix(filepath.Base(crtPath), ".crt")
|
||||||
|
// Unescape slash character
|
||||||
|
scope = strings.ReplaceAll(scope, ":", "/")
|
||||||
c.Add(scope, cert)
|
c.Add(scope, cert)
|
||||||
}
|
}
|
||||||
c.dir = true
|
c.dir = true
|
||||||
|
@ -134,6 +134,7 @@ func (c *Client) do(req *Request, via []*Request) (*Response, error) {
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
c.Certificates.Add(hostname+path, cert)
|
c.Certificates.Add(hostname+path, cert)
|
||||||
|
c.Certificates.Write(hostname+path, cert)
|
||||||
req.Certificate = &cert
|
req.Certificate = &cert
|
||||||
return c.do(req, via)
|
return c.do(req, via)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user