Golang crypto/x509.ParseCRL function example
package crypto/x509
ParseCRL parses a CRL from the given bytes. It's often the case that PEM encoded CRLs will appear where they should be DER encoded, so this function will transparently handle PEM encoding as long as there isn't any leading garbage.
Golang crypto/x509.ParseCRL function usage example
package main
import (
"crypto/x509"
"os"
"fmt"
)
func main() {
var crlBytes = `-----BEGIN X509 CRL-----
MIIBmjCCAQMwDQYJKoZIhvcNAQEEBQAwgb0xCzAJBgNVBAYTAlVTMRMwEQYDVQQI
EwpDYWxpZm9ybmlhMRAwDgYDVQQHEwdPYWtsYW5kMRYwFAYDVQQKEw1SZWQgSGF0
LCBJbmMuMSIwIAYDVQQLFBlHbG9iYWwgU2VydmljZXMgJiBTdXBwb3J0MR0wGwYD
VQQDExRSZWQgSGF0IFRlc3QgUm9vdCBDQTEsMCoGCSqGSIb3DQEJARYdc3Ryb25n
aG9sZC1zdXBwb3J0QHJlZGhhdC5jb20XDTAwMTExMzIwNTcyNVoXDTAwMTIxMzIw
NTcyNVowFDASAgEBFw0wMDA4MzEyMTE5MTdaMA0GCSqGSIb3DQEBBAUAA4GBAIge
X5VaOkNOKn8MrbxFiqpOrH/M9Vocu9oDeQ6EMTeA5xIWBGN53BZ/HUJ1NjS32VDG
waM3P6DXud4xKXauVgAXyH6D6xEDBt5GIBTFrWKIDKGOkvRChTUvzObmx9ZVSMMg
5xvAbsaFgJx3RBbznySlqVU4APYE0W2/xL0/8fzM
-----END X509 CRL-----`
certList, err := x509.ParseCRL([]byte(crlBytes))
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("TBSCertList : %v\n\n", certList.TBSCertList)
fmt.Printf("SignatureAlgorithm : %v\n\n", certList.SignatureAlgorithm)
fmt.Printf("SignatureValue : %v\n\n", certList.SignatureValue)
}
Reference :
Advertisement
Something interesting
Tutorials
+14.3k Golang : How to shuffle elements in array or slice?
+7.2k CloudFlare : Another way to get visitor's real IP address
+30.8k Golang : Download file example
+18.7k Unmarshal/Load CSV record into struct in Go
+19.9k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+7.9k Swift : Convert (cast) String to Float
+36.5k Golang : Validate IP address
+10.6k Golang : Flip coin example
+9k Golang : Inject/embed Javascript before sending out to browser example
+11.8k Golang : Verify Linux user password again before executing a program example
+16.4k Golang : Convert slice to array