Skip to content

Commit

Permalink
Add ALPN fields in fake test server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Aug 19, 2024
1 parent 99ea1d9 commit fc49864
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions credentials/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ func tlsServerHandshake(conn net.Conn) (AuthInfo, error) {
if err != nil {
return nil, err
}
serverTLSConfig := &tls.Config{Certificates: []tls.Certificate{cert}}
serverTLSConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
NextProtos: []string{"h2"},
}
serverConn := tls.Server(conn, serverTLSConfig)
err = serverConn.Handshake()
if err != nil {
Expand All @@ -307,7 +310,10 @@ func tlsServerHandshake(conn net.Conn) (AuthInfo, error) {
}

func tlsClientHandshake(conn net.Conn, _ string) (AuthInfo, error) {
clientTLSConfig := &tls.Config{InsecureSkipVerify: true}
clientTLSConfig := &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"h2"},
}
clientConn := tls.Client(conn, clientTLSConfig)
if err := clientConn.Handshake(); err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion credentials/xds/xds_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ func testServerTLSHandshake(rawConn net.Conn) handshakeResult {
if err != nil {
return handshakeResult{err: err}
}
cfg := &tls.Config{Certificates: []tls.Certificate{cert}}
cfg := &tls.Config{
Certificates: []tls.Certificate{cert},
NextProtos: []string{"h2"},
}
conn := tls.Server(rawConn, cfg)
if err := conn.Handshake(); err != nil {
return handshakeResult{err: err}
Expand Down
1 change: 1 addition & 0 deletions credentials/xds/xds_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func makeClientTLSConfig(t *testing.T, mTLS bool) *tls.Config {
// verification function. So, the server credentials tests will rely
// solely on the success/failure of the server-side handshake.
InsecureSkipVerify: true,
NextProtos: []string{"h2"},
}
}

Expand Down

0 comments on commit fc49864

Please sign in to comment.