mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
crypto/tls: simplify keylog tests.
Since there's no aspect of key logging that OpenSSL can check for us, the tests for it might as well just connect to another goroutine as this is lower-maintainance. Change-Id: I746d1dbad1b4bbfc8ef6ccf136ee4824dbda021e Reviewed-on: https://go-review.googlesource.com/30089 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Joonas Kuorilehto <joneskoo@derbian.fi> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
7b40b0c3a3
commit
2878cf14f3
6 changed files with 51 additions and 244 deletions
|
|
@ -747,43 +747,6 @@ func TestHandshakeServerECDHEECDSAAES(t *testing.T) {
|
|||
runServerTestTLS12(t, test)
|
||||
}
|
||||
|
||||
func TestHandshakeServerKeyLog(t *testing.T) {
|
||||
config := testConfig.Clone()
|
||||
buf := &bytes.Buffer{}
|
||||
config.KeyLogWriter = buf
|
||||
|
||||
test := &serverTest{
|
||||
name: "KeyLogWriter",
|
||||
command: []string{"openssl", "s_client"},
|
||||
config: config,
|
||||
validate: func(state ConnectionState) error {
|
||||
var format, clientRandom, masterSecret string
|
||||
if _, err := fmt.Fscanf(buf, "%s %s %s\n", &format, &clientRandom, &masterSecret); err != nil {
|
||||
return fmt.Errorf("failed to parse KeyLogWriter: " + err.Error())
|
||||
}
|
||||
if format != "CLIENT_RANDOM" {
|
||||
return fmt.Errorf("got key log format %q, wanted CLIENT_RANDOM", format)
|
||||
}
|
||||
// Both clientRandom and masterSecret are unpredictable in server handshake test
|
||||
if len(clientRandom) != 64 {
|
||||
return fmt.Errorf("got wrong length client random in key log %v, wanted 64", len(clientRandom))
|
||||
}
|
||||
if len(masterSecret) != 96 {
|
||||
return fmt.Errorf("got wrong length master secret in key log %v, want 96", len(masterSecret))
|
||||
}
|
||||
|
||||
// buf should contain no more lines
|
||||
var trailingGarbage string
|
||||
if _, err := fmt.Fscanln(buf, &trailingGarbage); err == nil {
|
||||
return fmt.Errorf("expected exactly one key in log, got trailing garbage %q", trailingGarbage)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
runServerTestTLS10(t, test)
|
||||
}
|
||||
|
||||
func TestHandshakeServerALPN(t *testing.T) {
|
||||
config := testConfig.Clone()
|
||||
config.NextProtos = []string{"proto1", "proto2"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue