space monkey internal commit export

[katamari commit: a6b35c2de3656d9e8b3654d78a850fa050652b1d]
This commit is contained in:
JT Olds 2014-02-28 09:43:31 -07:00
parent 9038b3bfc8
commit 754bf832c4

13
pem.go
View File

@ -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
}