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-p2p-tls
Commits
ec3177f9
Unverified
Commit
ec3177f9
authored
Apr 07, 2019
by
Marten Seemann
Committed by
GitHub
Apr 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #26 from libp2p/cert-prefix
use a prefix when signing the public key
parents
663747aa
8b173f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
crypto.go
crypto.go
+3
-2
No files found.
crypto.go
View file @
ec3177f9
...
...
@@ -21,6 +21,7 @@ import (
)
const
certValidityPeriod
=
100
*
365
*
24
*
time
.
Hour
// ~100 years
const
certificatePrefix
=
"libp2p-tls-handshake:"
var
extensionID
=
getPrefixedExtensionID
([]
int
{
1
,
1
})
...
...
@@ -139,7 +140,7 @@ func getRemotePubKey(chain []*x509.Certificate) (ic.PubKey, error) {
if
err
!=
nil
{
return
nil
,
err
}
valid
,
err
:=
pubKey
.
Verify
(
certKeyPub
,
sk
.
Signature
)
valid
,
err
:=
pubKey
.
Verify
(
append
([]
byte
(
certificatePrefix
),
certKeyPub
...
)
,
sk
.
Signature
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"signature verification failed: %s"
,
err
)
}
...
...
@@ -163,7 +164,7 @@ func keyToCertificate(sk ic.PrivKey) (*tls.Certificate, error) {
if
err
!=
nil
{
return
nil
,
err
}
signature
,
err
:=
sk
.
Sign
(
certKeyPub
)
signature
,
err
:=
sk
.
Sign
(
append
([]
byte
(
certificatePrefix
),
certKeyPub
...
)
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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