Update comments
This commit is contained in:
parent
b7e977f78a
commit
5edecf01a2
9
cert.go
9
cert.go
@ -98,10 +98,11 @@ func NewRawCertificate(host string, duration time.Duration) (crt, key []byte, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteCertificate writes the provided certificate and private key to name.crt + name.key
|
// WriteCertificate writes the provided certificate and private key
|
||||||
func WriteCertificate(name string, crt, key []byte) error {
|
// to path.crt and path.key respectively.
|
||||||
|
func WriteCertificate(path string, crt, key []byte) error {
|
||||||
// Write the certificate
|
// Write the certificate
|
||||||
crtPath := name + ".crt"
|
crtPath := path + ".crt"
|
||||||
crtOut, err := os.OpenFile(crtPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
crtOut, err := os.OpenFile(crtPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -111,7 +112,7 @@ func WriteCertificate(name string, crt, key []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the private key
|
// Write the private key
|
||||||
keyPath := name + ".key"
|
keyPath := path + ".key"
|
||||||
keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -311,8 +311,8 @@ func CertificateNotAuthorized(rw *ResponseWriter, req *Request) {
|
|||||||
rw.WriteHeader(StatusCertificateNotAuthorized, "Certificate not authorized")
|
rw.WriteHeader(StatusCertificateNotAuthorized, "Certificate not authorized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithCertificate responds with CertificateRequired if the client did not
|
// WithCertificate either responds with CertificateRequired if the client did
|
||||||
// provide a certificate, and calls f with the first ceritificate if they did.
|
// not provide a certificate, or calls f with the first ceritificate provided.
|
||||||
func WithCertificate(rw *ResponseWriter, req *Request, f func(*x509.Certificate)) {
|
func WithCertificate(rw *ResponseWriter, req *Request, f func(*x509.Certificate)) {
|
||||||
if len(req.TLS.PeerCertificates) == 0 {
|
if len(req.TLS.PeerCertificates) == 0 {
|
||||||
CertificateRequired(rw, req)
|
CertificateRequired(rw, req)
|
||||||
|
Loading…
Reference in New Issue
Block a user