Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-openssl
Commits
38a6bec6
Commit
38a6bec6
authored
Jun 13, 2020
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix comments
Signed-off-by:
Tiger
<
rbalajis25@gmail.com
>
parent
1fdf237b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
cert.go
cert.go
+4
-9
No files found.
cert.go
View file @
38a6bec6
...
@@ -333,7 +333,9 @@ func (c *Certificate) AddExtension(nid NID, value string) error {
...
@@ -333,7 +333,9 @@ func (c *Certificate) AddExtension(nid NID, value string) error {
// AddCustomExtension add custom extenstion to the certificate.
// AddCustomExtension add custom extenstion to the certificate.
func
(
c
*
Certificate
)
AddCustomExtension
(
nid
NID
,
value
[]
byte
)
error
{
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
errors
.
New
(
"Unable to add extension"
)
}
}
return
nil
return
nil
...
@@ -426,12 +428,5 @@ func (c *Certificate) SetVersion(version X509_Version) error {
...
@@ -426,12 +428,5 @@ func (c *Certificate) SetVersion(version X509_Version) error {
func
(
c
*
Certificate
)
GetExtensionValue
(
nid
NID
)
[]
byte
{
func
(
c
*
Certificate
)
GetExtensionValue
(
nid
NID
)
[]
byte
{
dataLength
:=
C
.
int
(
0
)
dataLength
:=
C
.
int
(
0
)
val
:=
C
.
get_extention
(
c
.
x
,
C
.
int
(
nid
),
&
dataLength
)
val
:=
C
.
get_extention
(
c
.
x
,
C
.
int
(
nid
),
&
dataLength
)
return
charToBytes
(
val
,
int
(
dataLength
))
return
C
.
GoBytes
(
unsafe
.
Pointer
(
val
),
dataLength
)
}
// 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
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment