fingerprint.go 296 B

12345678910111213
  1. package hpkp
  2. import (
  3. "crypto/sha256"
  4. "crypto/x509"
  5. "encoding/base64"
  6. )
  7. // Fingerprint returns the hpkp signature of an x509 certificate
  8. func Fingerprint(c *x509.Certificate) string {
  9. digest := sha256.Sum256(c.RawSubjectPublicKeyInfo)
  10. return base64.StdEncoding.EncodeToString(digest[:])
  11. }