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
+13.5k Facebook PHP getUser() returns 0
+7.3k Golang : How to iterate a slice without using for loop?
+11.8k Golang : convert(cast) float to string
+12.1k Golang : Decompress zlib file example
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+22.7k Golang : Strings to lowercase and uppercase example
+10.6k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+7.1k Nginx : How to block user agent ?
+35.5k Golang : Smarter Error Handling with strings.Contains()
+55.3k Golang : Unmarshal JSON from http response
+41.2k Golang : How to count duplicate items in slice/array?
+36.3k Golang : How to split or chunking a file to smaller pieces?