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
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+14.2k Golang : Fix image: unknown format error
+27.4k Golang : Convert CSV data to JSON format and save to file
+33k Golang : How to check if a date is within certain range?
+22.7k Golang : Set and Get HTTP request headers example
+19.2k Golang : Check whether a network interface is up on your machine
+29.9k Golang : Get and Set User-Agent examples
+16.4k Golang : How to implement two-factor authentication?
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+5.6k Fix fatal error: evacuation not done in time problem
+17.7k Golang : Read data from config file and assign to variables