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
+5k Golang : fmt.Println prints out empty data from struct
+12.4k Golang : Convert IPv4 address to packed 32-bit binary format
+14.9k Golang : Force download file example
+9k Golang : How to protect your source code from client, hosting company or hacker?
+16.6k Golang : How to tell if a file is compressed either gzip or zip ?
+19.2k Golang : Set or Add HTTP Request Headers
+21.6k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+22.3k Golang : Calculate time different
+6.8k Golang : Accessing dataframe-go element by row, column and name example
+5.5k Golang : Compound interest over time example
+7.5k Golang : Gomobile init produce "iphoneos" cannot be located error
+10.7k CodeIgniter : How to check if a session exist in PHP?