|
@@ -552,6 +552,7 @@ func LogCertificate(w http.ResponseWriter, cert *x509.Certificate) {
|
|
|
"serial": cert.SerialNumber.String(),
|
|
"serial": cert.SerialNumber.String(),
|
|
|
"subject": cert.Subject.CommonName,
|
|
"subject": cert.Subject.CommonName,
|
|
|
"issuer": cert.Issuer.CommonName,
|
|
"issuer": cert.Issuer.CommonName,
|
|
|
|
|
+ "sans": fmtSans(cert),
|
|
|
"valid-from": cert.NotBefore.Format(time.RFC3339),
|
|
"valid-from": cert.NotBefore.Format(time.RFC3339),
|
|
|
"valid-to": cert.NotAfter.Format(time.RFC3339),
|
|
"valid-to": cert.NotAfter.Format(time.RFC3339),
|
|
|
"public-key": fmtPublicKey(cert),
|
|
"public-key": fmtPublicKey(cert),
|
|
@@ -625,6 +626,31 @@ func ParseCursor(r *http.Request) (cursor string, limit int, err error) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func fmtSans(cert *x509.Certificate) map[string][]string {
|
|
|
|
|
+ sans := make(map[string][]string)
|
|
|
|
|
+ if len(cert.DNSNames) > 0 {
|
|
|
|
|
+ sans["dns"] = cert.DNSNames
|
|
|
|
|
+ }
|
|
|
|
|
+ if len(cert.EmailAddresses) > 0 {
|
|
|
|
|
+ sans["email"] = cert.EmailAddresses
|
|
|
|
|
+ }
|
|
|
|
|
+ if size := len(cert.IPAddresses); size > 0 {
|
|
|
|
|
+ ips := make([]string, size)
|
|
|
|
|
+ for i, ip := range cert.IPAddresses {
|
|
|
|
|
+ ips[i] = ip.String()
|
|
|
|
|
+ }
|
|
|
|
|
+ sans["ip"] = ips
|
|
|
|
|
+ }
|
|
|
|
|
+ if size := len(cert.URIs); size > 0 {
|
|
|
|
|
+ uris := make([]string, size)
|
|
|
|
|
+ for i, u := range cert.URIs {
|
|
|
|
|
+ uris[i] = u.String()
|
|
|
|
|
+ }
|
|
|
|
|
+ sans["uri"] = uris
|
|
|
|
|
+ }
|
|
|
|
|
+ return sans
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func fmtPublicKey(cert *x509.Certificate) string {
|
|
func fmtPublicKey(cert *x509.Certificate) string {
|
|
|
var params string
|
|
var params string
|
|
|
switch pk := cert.PublicKey.(type) {
|
|
switch pk := cert.PublicKey.(type) {
|