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
caaacc18
Commit
caaacc18
authored
Nov 24, 2019
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
close the underlying connection when the handshake fails
parent
8afeaef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
transport.go
transport.go
+10
-2
No files found.
transport.go
View file @
caaacc18
...
...
@@ -54,7 +54,11 @@ var _ sec.SecureTransport = &Transport{}
// SecureInbound runs the TLS handshake as a server.
func
(
t
*
Transport
)
SecureInbound
(
ctx
context
.
Context
,
insecure
net
.
Conn
)
(
sec
.
SecureConn
,
error
)
{
config
,
keyCh
:=
t
.
identity
.
ConfigForAny
()
return
t
.
handshake
(
ctx
,
tls
.
Server
(
insecure
,
config
),
keyCh
)
cs
,
err
:=
t
.
handshake
(
ctx
,
tls
.
Server
(
insecure
,
config
),
keyCh
)
if
err
!=
nil
{
insecure
.
Close
()
}
return
cs
,
err
}
// SecureOutbound runs the TLS handshake as a client.
...
...
@@ -66,7 +70,11 @@ func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn) (sec.S
// notice this after 1 RTT when calling Read.
func
(
t
*
Transport
)
SecureOutbound
(
ctx
context
.
Context
,
insecure
net
.
Conn
,
p
peer
.
ID
)
(
sec
.
SecureConn
,
error
)
{
config
,
keyCh
:=
t
.
identity
.
ConfigForPeer
(
p
)
return
t
.
handshake
(
ctx
,
tls
.
Client
(
insecure
,
config
),
keyCh
)
cs
,
err
:=
t
.
handshake
(
ctx
,
tls
.
Client
(
insecure
,
config
),
keyCh
)
if
err
!=
nil
{
insecure
.
Close
()
}
return
cs
,
err
}
func
(
t
*
Transport
)
handshake
(
...
...
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