2018-07-03 17:57:54 +01:00
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package tls
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto"
|
|
|
|
"crypto/x509"
|
2018-07-20 02:44:03 +01:00
|
|
|
"encoding/asn1"
|
|
|
|
"encoding/pem"
|
2018-07-03 17:57:54 +01:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
// A PEM-encoded "delegation certificate", an X.509 certificate with the
|
|
|
|
// DelegationUsage extension. The extension is defined in
|
|
|
|
// specified in https://tools.ietf.org/html/draft-ietf-tls-subcerts-01.
|
|
|
|
var dcDelegationCertPEM = `-----BEGIN CERTIFICATE-----
|
2018-07-03 17:57:54 +01:00
|
|
|
MIIBdzCCAR2gAwIBAgIQLVIvEpo0/0TzRja4ImvB1TAKBggqhkjOPQQDAjASMRAw
|
|
|
|
DgYDVQQKEwdBY21lIENvMB4XDTE4MDcwMzE2NTE1M1oXDTE5MDcwMzE2NTE1M1ow
|
|
|
|
EjEQMA4GA1UEChMHQWNtZSBDbzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABOhB
|
|
|
|
U6adaAgliLaFc1PAo9HBO4Wish1G4df3IK5EXLy+ooYfmkfzT1FxqbNLZufNYzve
|
|
|
|
25fmpal/1VJAjpVyKq2jVTBTMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggr
|
|
|
|
BgEFBQcDATAMBgNVHRMBAf8EAjAAMA8GA1UdEQQIMAaHBH8AAAEwDQYJKwYBBAGC
|
|
|
|
2kssBAAwCgYIKoZIzj0EAwIDSAAwRQIhAPNwRk6cygm6zO5rjOzohKYWS+1KuWCM
|
|
|
|
OetDIvU4mdyoAiAGN97y3GJccYn9ZOJS4UOqhr9oO8PuZMLgdq4OrMRiiA==
|
|
|
|
-----END CERTIFICATE-----
|
|
|
|
`
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
// The PEM-encoded "delegation key", the secret key associated with the
|
|
|
|
// delegation certificate.
|
|
|
|
var dcDelegationKeyPEM = `-----BEGIN EC PRIVATE KEY-----
|
2018-07-03 17:57:54 +01:00
|
|
|
MHcCAQEEIJDVlo+sJolMcNjMkfCGDUjMJcE4UgclcXGCrOtbJAi2oAoGCCqGSM49
|
|
|
|
AwEHoUQDQgAE6EFTpp1oCCWItoVzU8Cj0cE7haKyHUbh1/cgrkRcvL6ihh+aR/NP
|
|
|
|
UXGps0tm581jO97bl+alqX/VUkCOlXIqrQ==
|
|
|
|
-----END EC PRIVATE KEY-----
|
|
|
|
`
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
// A certificate without the DelegationUsage extension.
|
|
|
|
var dcCertPEM = `-----BEGIN CERTIFICATE-----
|
2018-07-03 17:57:54 +01:00
|
|
|
MIIBaTCCAQ6gAwIBAgIQSUo+9uaip3qCW+1EPeHZgDAKBggqhkjOPQQDAjASMRAw
|
|
|
|
DgYDVQQKEwdBY21lIENvMB4XDTE4MDYxMjIzNDAyNloXDTE5MDYxMjIzNDAyNlow
|
|
|
|
EjEQMA4GA1UEChMHQWNtZSBDbzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABLf7
|
|
|
|
fiznPVdc3V5mM3ymswU2/IoJaq/deA6dgdj50ozdYyRiAPjxzcz9zRsZw1apTF/h
|
|
|
|
yNfiLhV4EE1VrwXcT5OjRjBEMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggr
|
|
|
|
BgEFBQcDATAMBgNVHRMBAf8EAjAAMA8GA1UdEQQIMAaHBH8AAAEwCgYIKoZIzj0E
|
|
|
|
AwIDSQAwRgIhANXG0zmrVtQBK0TNZZoEGMOtSwxmiZzXNe+IjdpxO3TiAiEA5VYx
|
|
|
|
0CWJq5zqpVXbJMeKVMASo2nrXZoA6NhJvFQ97hw=
|
|
|
|
-----END CERTIFICATE-----
|
|
|
|
`
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
// The secret key associatted with dcCertPEM.
|
|
|
|
var dcKeyPEM = `-----BEGIN EC PRIVATE KEY-----
|
2018-07-03 17:57:54 +01:00
|
|
|
MHcCAQEEIMw9DiOfGI1E/XZrrW2huZSjYi0EKwvVjAe+dYtyFsSloAoGCCqGSM49
|
|
|
|
AwEHoUQDQgAEt/t+LOc9V1zdXmYzfKazBTb8iglqr914Dp2B2PnSjN1jJGIA+PHN
|
|
|
|
zP3NGxnDVqlMX+HI1+IuFXgQTVWvBdxPkw==
|
|
|
|
-----END EC PRIVATE KEY-----
|
|
|
|
`
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
// dcTestDC stores delegated credentials and their secret keys.
|
|
|
|
type dcTestDC struct {
|
|
|
|
Name string
|
|
|
|
Version int
|
|
|
|
Scheme int
|
|
|
|
DC []byte
|
|
|
|
PrivateKey []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test data used for testing the TLS handshake with the delegated creedential
|
|
|
|
// extension. The PEM block encodes a DER encoded slice of dcTestDC's.
|
2018-07-20 02:44:03 +01:00
|
|
|
var dcTestDCsPEM = `-----BEGIN DC TEST DATA-----
|
|
|
|
MIIGQzCCAToTBXRsczEyAgIDAwICBAMEga0ACUp3AFswWTATBgcqhkjOPQIBBggq
|
|
|
|
hkjOPQMBBwNCAAQ9z9RDrMvyRzPOkw9SK2S/O5DiwfRNjAwYcq7e/sKdN0ZcSP1K
|
|
|
|
se/+ZDXfruwyviuq+h5oSzWPoejHHx7jnwBTBAMASDBGAiEAtYH/x0Ue2B2a34WG
|
|
|
|
Oj9wVPJeyYBXxIbUrCdqfoQzq2oCIQCJYtwRE9UJvAQKve4ulJOr+zGjN8jG4tdg
|
|
|
|
9YSb/yOQgQR5MHcCAQEEIOBCmSaGwzZtXOJRCbA03GgxegoSV5GasVjJlttpUAPh
|
|
|
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07-03 17:57:54 +01:00
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
var dcTestDCs []dcTestDC
|
|
|
|
var dcTestConfig *Config
|
|
|
|
var dcTestDelegationCert Certificate
|
|
|
|
var dcTestCert Certificate
|
|
|
|
var dcTestNow time.Time
|
|
|
|
|
2018-07-03 17:57:54 +01:00
|
|
|
func init() {
|
2018-07-20 17:47:24 +01:00
|
|
|
// Parse the PEM block containing the test DCs.
|
2018-07-20 02:44:03 +01:00
|
|
|
block, _ := pem.Decode([]byte(dcTestDCsPEM))
|
|
|
|
if block == nil {
|
|
|
|
panic("failed to decode DC tests PEM block")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the DER-encoded test DCs.
|
|
|
|
_, err := asn1.Unmarshal(block.Bytes, &dcTestDCs)
|
|
|
|
if err != nil {
|
|
|
|
panic("failed to unmarshal DC test ASN.1 data")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use a static time for testing. This is the point at which the test DCs
|
|
|
|
// were generated.
|
|
|
|
dcTestNow = time.Date(2018, 07, 03, 18, 0, 0, 234234, time.UTC)
|
2018-07-03 17:57:54 +01:00
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// The base configuration for the client and server.
|
2018-07-03 17:57:54 +01:00
|
|
|
dcTestConfig = &Config{
|
|
|
|
Time: func() time.Time {
|
2018-07-20 02:44:03 +01:00
|
|
|
return dcTestNow
|
2018-07-03 17:57:54 +01:00
|
|
|
},
|
|
|
|
Rand: zeroSource{},
|
|
|
|
Certificates: nil,
|
|
|
|
MinVersion: VersionTLS10,
|
2018-08-07 18:52:06 +01:00
|
|
|
MaxVersion: VersionTLS13,
|
2018-07-03 17:57:54 +01:00
|
|
|
CipherSuites: allCipherSuites(),
|
|
|
|
}
|
|
|
|
|
|
|
|
// The delegation certificate.
|
2018-07-20 17:47:24 +01:00
|
|
|
dcTestDelegationCert, err = X509KeyPair([]byte(dcDelegationCertPEM), []byte(dcDelegationKeyPEM))
|
2018-07-03 17:57:54 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-07-20 02:44:03 +01:00
|
|
|
dcTestDelegationCert.Leaf, err = x509.ParseCertificate(dcTestDelegationCert.Certificate[0])
|
2018-07-03 17:57:54 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// A certificate without the the DelegationUsage extension for X.509.
|
2018-07-20 17:47:24 +01:00
|
|
|
dcTestCert, err = X509KeyPair([]byte(dcCertPEM), []byte(dcKeyPEM))
|
2018-07-03 17:57:54 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-07-20 02:44:03 +01:00
|
|
|
dcTestCert.Leaf, err = x509.ParseCertificate(dcTestCert.Certificate[0])
|
2018-07-03 17:57:54 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// Make these roots of these certificates the client's trusted CAs.
|
2018-07-03 17:57:54 +01:00
|
|
|
dcTestConfig.RootCAs = x509.NewCertPool()
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
raw := dcTestDelegationCert.Certificate[len(dcTestDelegationCert.Certificate)-1]
|
|
|
|
root, err := x509.ParseCertificate(raw)
|
2018-07-03 17:57:54 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-07-20 02:44:03 +01:00
|
|
|
dcTestConfig.RootCAs.AddCert(root)
|
2018-07-03 17:57:54 +01:00
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
raw = dcTestCert.Certificate[len(dcTestCert.Certificate)-1]
|
|
|
|
root, err = x509.ParseCertificate(raw)
|
2018-07-03 17:57:54 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-07-20 02:44:03 +01:00
|
|
|
dcTestConfig.RootCAs.AddCert(root)
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
// Executes the handshake with the given configuration and returns true if the
|
|
|
|
// delegated credential extension was successfully negotiated.
|
|
|
|
func testConnWithDC(t *testing.T, clientConfig, serverConfig *Config) (bool, error) {
|
2018-07-03 17:57:54 +01:00
|
|
|
ln := newLocalListener(t)
|
|
|
|
defer ln.Close()
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// Listen for and serve a single client connection.
|
2018-07-03 17:57:54 +01:00
|
|
|
srvCh := make(chan *Conn, 1)
|
|
|
|
var serr error
|
|
|
|
go func() {
|
|
|
|
sconn, err := ln.Accept()
|
|
|
|
if err != nil {
|
|
|
|
serr = err
|
|
|
|
srvCh <- nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
srv := Server(sconn, serverConfig)
|
|
|
|
if err := srv.Handshake(); err != nil {
|
|
|
|
serr = fmt.Errorf("handshake: %v", err)
|
|
|
|
srvCh <- nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
srvCh <- srv
|
|
|
|
}()
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// Dial the server.
|
2018-07-03 17:57:54 +01:00
|
|
|
cli, err := Dial("tcp", ln.Addr().String(), clientConfig)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
defer cli.Close()
|
|
|
|
|
|
|
|
srv := <-srvCh
|
|
|
|
if srv == nil {
|
|
|
|
return false, serr
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return true if the client's conn.dc structure was instantiated.
|
2018-07-20 17:47:24 +01:00
|
|
|
st := cli.ConnectionState()
|
|
|
|
return (st.DelegatedCredential != nil), nil
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Checks that the client suppports a version >= 1.2 and accepts delegated
|
|
|
|
// credentials. If so, it returns the delegation certificate; otherwise it
|
|
|
|
// returns a plain certificate.
|
|
|
|
func testServerGetCertificate(ch *ClientHelloInfo) (*Certificate, error) {
|
|
|
|
versOk := false
|
|
|
|
for _, vers := range ch.SupportedVersions {
|
|
|
|
versOk = versOk || (vers >= uint16(VersionTLS12))
|
|
|
|
}
|
|
|
|
|
|
|
|
if versOk && ch.AcceptsDelegatedCredential {
|
2018-07-20 02:44:03 +01:00
|
|
|
return &dcTestDelegationCert, nil
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
2018-07-20 02:44:03 +01:00
|
|
|
return &dcTestCert, nil
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// Various test cases for handshakes involving DCs.
|
2018-07-20 17:47:24 +01:00
|
|
|
var dcTesters = []struct {
|
2018-07-03 17:57:54 +01:00
|
|
|
clientDC bool
|
|
|
|
serverDC bool
|
|
|
|
clientSkipVerify bool
|
|
|
|
clientMaxVers uint16
|
|
|
|
serverMaxVers uint16
|
2018-07-20 02:44:03 +01:00
|
|
|
nowOffset time.Duration
|
|
|
|
dcTestName string
|
2018-07-03 17:57:54 +01:00
|
|
|
expectSuccess bool
|
|
|
|
expectDC bool
|
|
|
|
name string
|
|
|
|
}{
|
2018-07-20 02:44:03 +01:00
|
|
|
{true, true, false, VersionTLS12, VersionTLS12, 0, "tls12", true, true, "tls12"},
|
|
|
|
{true, true, false, VersionTLS13, VersionTLS13, 0, "tls13", true, true, "tls13"},
|
|
|
|
{true, true, false, VersionTLS12, VersionTLS12, 0, "malformed12", false, false, "tls12, malformed dc"},
|
|
|
|
{true, true, false, VersionTLS13, VersionTLS13, 0, "malformed13", false, false, "tls13, malformed dc"},
|
|
|
|
{true, true, true, VersionTLS12, VersionTLS12, 0, "invalid", true, true, "tls12, invalid dc, skip verify"},
|
|
|
|
{true, true, true, VersionTLS13, VersionTLS13, 0, "invalid", true, true, "tls13, invalid dc, skip verify"},
|
|
|
|
{false, true, false, VersionTLS12, VersionTLS12, 0, "tls12", true, false, "client no dc"},
|
|
|
|
{true, false, false, VersionTLS12, VersionTLS12, 0, "tls12", true, false, "server no dc"},
|
|
|
|
{true, true, false, VersionTLS11, VersionTLS12, 0, "tls12", true, false, "client old"},
|
|
|
|
{true, true, false, VersionTLS12, VersionTLS11, 0, "tls12", true, false, "server old"},
|
|
|
|
{true, true, false, VersionTLS13, VersionTLS13, dcMaxTTL, "tls13", false, false, "expired dc"},
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
|
2018-07-20 02:44:03 +01:00
|
|
|
// Tests the handshake with the delegated credential extension for each test
|
|
|
|
// case in dcTests.
|
2018-07-03 17:57:54 +01:00
|
|
|
func TestDCHandshake(t *testing.T) {
|
|
|
|
clientConfig := dcTestConfig.Clone()
|
|
|
|
serverConfig := dcTestConfig.Clone()
|
|
|
|
serverConfig.GetCertificate = testServerGetCertificate
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
for i, tester := range dcTesters {
|
|
|
|
clientConfig.MaxVersion = tester.clientMaxVers
|
|
|
|
serverConfig.MaxVersion = tester.serverMaxVers
|
|
|
|
clientConfig.InsecureSkipVerify = tester.clientSkipVerify
|
|
|
|
clientConfig.AcceptDelegatedCredential = tester.clientDC
|
2018-07-20 02:44:03 +01:00
|
|
|
clientConfig.Time = func() time.Time {
|
2018-07-20 17:47:24 +01:00
|
|
|
return dcTestNow.Add(time.Duration(tester.nowOffset))
|
2018-07-20 02:44:03 +01:00
|
|
|
}
|
2018-07-03 17:57:54 +01:00
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
if tester.serverDC {
|
2018-07-20 02:44:03 +01:00
|
|
|
serverConfig.GetDelegatedCredential = func(
|
2018-07-20 17:47:24 +01:00
|
|
|
ch *ClientHelloInfo, vers uint16) ([]byte, crypto.PrivateKey, error) {
|
|
|
|
for _, test := range dcTestDCs {
|
|
|
|
if test.Name == tester.dcTestName {
|
|
|
|
sk, err := x509.ParseECPrivateKey(test.PrivateKey)
|
2018-07-20 02:44:03 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
2018-07-20 17:47:24 +01:00
|
|
|
return test.DC, sk, nil
|
2018-07-20 02:44:03 +01:00
|
|
|
}
|
|
|
|
}
|
2018-07-20 17:47:24 +01:00
|
|
|
return nil, nil, fmt.Errorf("Test DC with name '%s' not found", tester.dcTestName)
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
serverConfig.GetDelegatedCredential = nil
|
|
|
|
}
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
usedDC, err := testConnWithDC(t, clientConfig, serverConfig)
|
|
|
|
if err != nil && tester.expectSuccess {
|
|
|
|
t.Errorf("test #%d (%s) fails: %s", i+1, tester.name, err)
|
|
|
|
} else if err == nil && !tester.expectSuccess {
|
|
|
|
t.Errorf("test #%d (%s) succeeds; expected failure", i+1, tester.name)
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
|
2018-07-20 17:47:24 +01:00
|
|
|
if usedDC != tester.expectDC {
|
|
|
|
t.Errorf("test #%d (%s) usedDC = %v; expected %v", i+1, tester.name, usedDC, tester.expectDC)
|
2018-07-03 17:57:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|