Skip to content

Commit

Permalink
space monkey internal commit export
Browse files Browse the repository at this point in the history
[katamari commit: a6b35c2de3656d9e8b3654d78a850fa050652b1d]
  • Loading branch information
jtolio committed Feb 28, 2014
1 parent 9038b3b commit 754bf83
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}

0 comments on commit 754bf83

Please sign in to comment.