mirror of
https://github.com/libp2p/go-openssl.git
synced 2024-12-26 23:40:07 +08:00
space monkey internal commit export
[katamari commit: a6b35c2de3656d9e8b3654d78a850fa050652b1d]
This commit is contained in:
parent
9038b3bfc8
commit
754bf832c4
13
pem.go
13
pem.go
@ -5,6 +5,8 @@ package openssl
|
||||
|
||||
// #include <openssl/ssl.h>
|
||||
// #include <openssl/conf.h>
|
||||
//
|
||||
// void OPENSSL_free_not_a_macro(void *ref) { OPENSSL_free(ref); }
|
||||
import "C"
|
||||
|
||||
import (
|
||||
@ -202,3 +204,14 @@ func (c *Certificate) PublicKey() (PublicKey, error) {
|
||||
})
|
||||
return key, nil
|
||||
}
|
||||
|
||||
// GetSerialNumberHex returns the certificate's serial number in hex format
|
||||
func (c *Certificate) GetSerialNumberHex() (serial string) {
|
||||
asn1_i := C.X509_get_serialNumber(c.x)
|
||||
bignum := C.ASN1_INTEGER_to_BN(asn1_i, nil)
|
||||
hex := C.BN_bn2hex(bignum)
|
||||
serial = C.GoString(hex)
|
||||
C.BN_free(bignum)
|
||||
C.OPENSSL_free_not_a_macro(unsafe.Pointer(hex))
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user