Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
Signed-off-by: Tiger <[email protected]>
  • Loading branch information
poonai committed Jun 7, 2020
1 parent 1fdf237 commit 8e2cfff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ func (c *Certificate) AddExtension(nid NID, value string) error {

// AddCustomExtension add custom extenstion to the certificate.
func (c *Certificate) AddCustomExtension(nid NID, value []byte) error {
if int(C.add_custom_ext(c.x, C.int(nid), (*C.char)(C.CBytes(value)), C.int(len(value)))) == 0 {
val := (*C.char)(C.CBytes(value))
defer C.free(unsafe.Pointer(val))
if int(C.add_custom_ext(c.x, C.int(nid), val, C.int(len(value)))) == 0 {
return errors.New("Unable to add extension")
}
return nil
Expand Down Expand Up @@ -431,7 +433,5 @@ func (c *Certificate) GetExtensionValue(nid NID) []byte {

// charToBytes converts c unisgned char to golang bytes
func charToBytes(src *C.uchar, sz int) []byte {
dest := make([]byte, sz)
copy(dest, (*(*[1024]byte)(unsafe.Pointer(src)))[:sz:sz])
return dest
return (*(*[1 << 31]byte)(unsafe.Pointer(src)))[:sz:sz]
}

0 comments on commit 8e2cfff

Please sign in to comment.