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
+5.8k PHP : Fix Call to undefined function curl_init() error
+16.3k Golang : Get sub string example
+8.6k Golang : Configure Apache and NGINX to access your Go service example
+34k Golang : convert(cast) bytes to string
+10.1k Golang : interface - when and where to use examples
+6.2k Golang : Compound interest over time example
+15k Golang : Normalize unicode strings for comparison purpose
+7.6k Golang : File system scanning
+7.3k Golang : constant 20013 overflows byte error message
+5.6k Golang : Return multiple values from function
+11.9k Golang : Fuzzy string search or approximate string matching example
+14k Golang : Get user input until a command or receive a word to stop