-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes golang/go#71612 Change-Id: I5cb0596b33cb18016eb1883d1518319588ae1454 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/647975 Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Nicola Murino <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Nicola Murino <[email protected]>
- Loading branch information
1 parent
9290511
commit e47973b
Showing
3 changed files
with
9 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,12 @@ import ( | |
"reflect" | ||
"testing" | ||
"time" | ||
) | ||
|
||
// Cert generated by ssh-keygen 6.0p1 Debian-4. | ||
// % ssh-keygen -s ca-key -I test user-key | ||
const exampleSSHCert = `[email protected] AAAAHHNzaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAgb1srW/W3ZDjYAO45xLYAwzHBDLsJ4Ux6ICFIkTjb1LEAAAADAQABAAAAYQCkoR51poH0wE8w72cqSB8Sszx+vAhzcMdCO0wqHTj7UNENHWEXGrU0E0UQekD7U+yhkhtoyjbPOVIP7hNa6aRk/ezdh/iUnCIt4Jt1v3Z1h1P+hA4QuYFMHNB+rmjPwAcAAAAAAAAAAAAAAAEAAAAEdGVzdAAAAAAAAAAAAAAAAP//////////AAAAAAAAAIIAAAAVcGVybWl0LVgxMS1mb3J3YXJkaW5nAAAAAAAAABdwZXJtaXQtYWdlbnQtZm9yd2FyZGluZwAAAAAAAAAWcGVybWl0LXBvcnQtZm9yd2FyZGluZwAAAAAAAAAKcGVybWl0LXB0eQAAAAAAAAAOcGVybWl0LXVzZXItcmMAAAAAAAAAAAAAAHcAAAAHc3NoLXJzYQAAAAMBAAEAAABhANFS2kaktpSGc+CcmEKPyw9mJC4nZKxHKTgLVZeaGbFZOvJTNzBspQHdy7Q1uKSfktxpgjZnksiu/tFF9ngyY2KFoc+U88ya95IZUycBGCUbBQ8+bhDtw/icdDGQD5WnUwAAAG8AAAAHc3NoLXJzYQAAAGC8Y9Z2LQKhIhxf52773XaWrXdxP0t3GBVo4A10vUWiYoAGepr6rQIoGGXFxT4B9Gp+nEBJjOwKDXPrAevow0T9ca8gZN+0ykbhSrXLE5Ao48rqr3zP4O1/9P7e6gp0gw8=` | ||
"golang.org/x/crypto/ssh/testdata" | ||
) | ||
|
||
func TestParseCert(t *testing.T) { | ||
authKeyBytes := []byte(exampleSSHCert) | ||
authKeyBytes := bytes.TrimSuffix(testdata.SSHCertificates["rsa"], []byte(" host.example.com\n")) | ||
|
||
key, _, _, rest, err := ParseAuthorizedKey(authKeyBytes) | ||
if err != nil { | ||
|
@@ -103,7 +101,7 @@ func TestParseCertWithOptions(t *testing.T) { | |
} | ||
|
||
func TestValidateCert(t *testing.T) { | ||
key, _, _, _, err := ParseAuthorizedKey([]byte(exampleSSHCert)) | ||
key, _, _, _, err := ParseAuthorizedKey(testdata.SSHCertificates["rsa-user-testcertificate"]) | ||
if err != nil { | ||
t.Fatalf("ParseAuthorizedKey: %v", err) | ||
} | ||
|
@@ -116,7 +114,7 @@ func TestValidateCert(t *testing.T) { | |
return bytes.Equal(k.Marshal(), validCert.SignatureKey.Marshal()) | ||
} | ||
|
||
if err := checker.CheckCert("user", validCert); err != nil { | ||
if err := checker.CheckCert("testcertificate", validCert); err != nil { | ||
t.Errorf("Unable to validate certificate: %v", err) | ||
} | ||
invalidCert := &Certificate{ | ||
|
@@ -125,7 +123,7 @@ func TestValidateCert(t *testing.T) { | |
ValidBefore: CertTimeInfinity, | ||
Signature: &Signature{}, | ||
} | ||
if err := checker.CheckCert("user", invalidCert); err == nil { | ||
if err := checker.CheckCert("testcertificate", invalidCert); err == nil { | ||
t.Error("Invalid cert signature passed validation") | ||
} | ||
} | ||
|