mirror of
https://github.com/libp2p/go-openssl.git
synced 2025-02-05 06:20:08 +08:00
fix a leak and compiler error
This commit is contained in:
parent
5230a35d68
commit
e6f40e41ef
@ -107,7 +107,7 @@ func TestCertGetNameEntry(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info := &CertificateInfo{
|
||||
Serial: 1,
|
||||
Serial: big.NewInt(int64(1)),
|
||||
Issued: 0,
|
||||
Expires: 24 * time.Hour,
|
||||
Country: "US",
|
||||
|
4
key.go
4
key.go
@ -245,7 +245,8 @@ func LoadPrivateKeyFromPEM(pem_block []byte) (PrivateKey, error) {
|
||||
}
|
||||
|
||||
// LoadPrivateKeyFromPEM loads a private key from a PEM-encoded block.
|
||||
func LoadPrivateKeyFromPEMWidthPassword(pem_block []byte, password string) (PrivateKey, error) {
|
||||
func LoadPrivateKeyFromPEMWidthPassword(pem_block []byte, password string) (
|
||||
PrivateKey, error) {
|
||||
if len(pem_block) == 0 {
|
||||
return nil, errors.New("empty pem block")
|
||||
}
|
||||
@ -256,6 +257,7 @@ func LoadPrivateKeyFromPEMWidthPassword(pem_block []byte, password string) (Priv
|
||||
}
|
||||
defer C.BIO_free(bio)
|
||||
cs := C.CString(password)
|
||||
defer C.free(unsafe.Pointer(cs))
|
||||
rsakey := C.PEM_read_bio_RSAPrivateKey(bio, nil, nil, unsafe.Pointer(cs))
|
||||
if rsakey == nil {
|
||||
return nil, errors.New("failed reading rsa key")
|
||||
|
Loading…
Reference in New Issue
Block a user