Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 04:00 UTC
caddyhttp: Placeholder for client cert in DER + base64 format (#4241)
* client.certificate_pem_encoded in base64 format * base64-encoding without pem encoding;naming change * fix cert.Raw instead of block.bytes
Oleg committed
Oct 2, 2021 at 01:27 UTC
cbb045a121464527d85cce1b56250480b0515f9a
3 files changed
+5
caddyconfig/httpcaddyfile/httptype.go
+1
@@ -113,6 +113,7 @@ func (st ServerType) Setup(inputServerBlocks []caddyfile.ServerBlock,
113
"{tls_client_serial}", "{http.request.tls.client.serial}",
114
"{tls_client_subject}", "{http.request.tls.client.subject}",
115
"{tls_client_certificate_pem}", "{http.request.tls.client.certificate_pem}",
116
+ "{tls_client_certificate_der_base64}", "{http.request.tls.client.certificate_der_base64}",
117
"{upstream_hostport}", "{http.reverse_proxy.upstream.hostport}",
118
)
119
modules/caddyhttp/app.go
+1
@@ -77,6 +77,7 @@ func init() {
77
// `{http.request.tls.client.public_key}` | The public key of the client certificate.
78
// `{http.request.tls.client.public_key_sha256}` | The SHA256 checksum of the client's public key.
79
// `{http.request.tls.client.certificate_pem}` | The PEM-encoded value of the certificate.
80
+// `{http.request.tls.client.certificate_der_base64}` | The base64-encoded value of the certificate.
81
// `{http.request.tls.client.issuer}` | The issuer DN of the client certificate
82
// `{http.request.tls.client.serial}` | The serial number of the client certificate
83
// `{http.request.tls.client.subject}` | The subject DN of the client certificate
modules/caddyhttp/replacer.go
+3
@@ -25,6 +25,7 @@ import (
25
"crypto/tls"
26
"crypto/x509"
27
"encoding/asn1"
28
+ "encoding/base64"
29
"encoding/pem"
30
"fmt"
31
"io"
@@ -352,6 +353,8 @@ func getReqTLSReplacement(req *http.Request, key string) (interface{}, bool) {
353
case "client.certificate_pem":
354
block := pem.Block{Type: "CERTIFICATE", Bytes: cert.Raw}
355
return pem.EncodeToMemory(&block), true
356
+ case "client.certificate_der_base64":
357
+ return base64.StdEncoding.EncodeToString(cert.Raw), true
358
default:
359
return nil, false
360
}