Golang crypto/x509.Certificate.CheckSignature() function example
package crypto/x509
CheckSignature verifies that signature is a valid signature over signed from the given certificate's public key.
Golang crypto/x509.Certificate.CheckSignature() function usage
var signature []byte
err = cert.CheckSignature(x509.SHA256WithRSA, []byte(signingString), signature)
if err != nil {
fmt.Println("Key is not a valid RSA public key")
os.Exit(1)
}
or
if err := x509.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature); err != nil {
fmt.Println("Corrupted signature on embedded certificate")
}
Reference :
http://golang.org/pkg/crypto/x509/#Certificate.CheckSignature
Advertisement
Something interesting
Tutorials
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+11.9k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat
+17.6k Golang : Upload/Receive file progress indicator
+12.1k Golang : convert(cast) string to integer value
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+25.8k Golang : Daemonizing a simple web server process example
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+14.5k Golang : How to determine if user agent is a mobile device example
+9.7k Random number generation with crypto/rand in Go
+7.3k Golang : alternative to os.Exit() function