Golang crypto/x509.SignatureAlgorithm type example
package crypto/x509
Golang crypto/x509.SignatureAlgorithm type usage examples
if err := x509.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature); err != nil {
fmt.Println("Corrupted signature on embedded certificate")
}
or
switch {
case x509Cert.SignatureAlgorithm == x509.MD2WithRSA:
return "MD2WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.MD5WithRSA:
return "MD5WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA1WithRSA:
return "SHA1WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA256WithRSA:
return "SHA256WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA384WithRSA:
return "SHA384WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.SHA512WithRSA:
return "SHA512WithRSA Algorithm"
case x509Cert.SignatureAlgorithm == x509.DSAWithSHA1:
return "DSAWithSHA1 Algorithm"
case x509Cert.SignatureAlgorithm == x509.DSAWithSHA256:
return "DSAWithSHA256 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA1:
return "ECDSAWithSHA1 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA256:
return "ECDSAWithSHA256 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA384:
return "ECDSAWithSHA384 Algorithm"
case x509Cert.SignatureAlgorithm == x509.ECDSAWithSHA512:
return "ECDSAWithSHA512 Algorithm"
default:
return "UnknownSignatureAlgorithm"
}
Reference :
Advertisement
Something interesting
Tutorials
+19.6k Golang : Close channel after ticker stopped example
+6.5k Golang : Map within a map example
+7.6k SSL : How to check if current certificate is sha1 or sha2 from command line
+14.8k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+13.6k Golang : Strings comparison
+26.7k Golang : How to check if a connection to database is still alive ?
+4.7k Adding Skype actions such as call and chat into web page examples
+23.5k Golang : Read a file into an array or slice example
+7k Golang : Levenshtein distance example
+13.6k Golang : reCAPTCHA example