|
8 | 8 | "crypto/rand" |
9 | 9 | "crypto/sha256" |
10 | 10 | "encoding/json" |
11 | | - "encoding/pem" |
12 | 11 | "errors" |
13 | 12 | "fmt" |
14 | 13 | "io" |
@@ -78,7 +77,7 @@ func TestEnroll(t *testing.T) { |
78 | 77 | HostID: hostID, |
79 | 78 | Counter: counter, |
80 | 79 | Config: cfg, |
81 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 80 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
82 | 81 | Organization: message.HostOrgMetadata{ |
83 | 82 | ID: orgID, |
84 | 83 | Name: orgName, |
@@ -209,7 +208,7 @@ func TestDoUpdate(t *testing.T) { |
209 | 208 | HostID: "foobar", |
210 | 209 | Counter: 1, |
211 | 210 | Config: cfg, |
212 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 211 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
213 | 212 | Organization: message.HostOrgMetadata{ |
214 | 213 | ID: "foobaz", |
215 | 214 | Name: "foobar's foo org", |
@@ -278,7 +277,7 @@ func TestDoUpdate(t *testing.T) { |
278 | 277 | Config: dnapitest.NebulaCfg(caPEM), |
279 | 278 | Counter: 2, |
280 | 279 | Nonce: dnapitest.GetNonce(r), |
281 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 280 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
282 | 281 | Organization: message.HostOrgMetadata{ |
283 | 282 | ID: "foobaz", |
284 | 283 | Name: "foobar's foo org", |
@@ -333,7 +332,7 @@ func TestDoUpdate(t *testing.T) { |
333 | 332 | Config: dnapitest.NebulaCfg(caPEM), |
334 | 333 | Counter: 0, |
335 | 334 | Nonce: dnapitest.GetNonce(r), |
336 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 335 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
337 | 336 | Organization: message.HostOrgMetadata{ |
338 | 337 | ID: "foobaz", |
339 | 338 | Name: "foobar's foo org", |
@@ -393,7 +392,7 @@ func TestDoUpdate(t *testing.T) { |
393 | 392 | Config: dnapitest.NebulaCfg(caPEM), |
394 | 393 | Counter: 3, |
395 | 394 | Nonce: dnapitest.GetNonce(r), |
396 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 395 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
397 | 396 | Organization: message.HostOrgMetadata{ |
398 | 397 | ID: orgID, |
399 | 398 | Name: orgName, |
@@ -480,7 +479,7 @@ func TestDoUpdate_P256(t *testing.T) { |
480 | 479 | HostID: "foobar", |
481 | 480 | Counter: 1, |
482 | 481 | Config: cfg, |
483 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 482 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
484 | 483 | Organization: message.HostOrgMetadata{ |
485 | 484 | ID: "foobaz", |
486 | 485 | Name: "foobar's foo org", |
@@ -638,7 +637,7 @@ func TestDoUpdate_P256(t *testing.T) { |
638 | 637 | Config: dnapitest.NebulaCfg(caPEM), |
639 | 638 | Counter: 3, |
640 | 639 | Nonce: dnapitest.GetNonce(r), |
641 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 640 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
642 | 641 | Organization: message.HostOrgMetadata{ |
643 | 642 | ID: "foobaz", |
644 | 643 | Name: "foobar's foo org", |
@@ -720,7 +719,7 @@ func TestCommandResponse(t *testing.T) { |
720 | 719 | HostID: "foobar", |
721 | 720 | Counter: 1, |
722 | 721 | Config: cfg, |
723 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 722 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
724 | 723 | Organization: message.HostOrgMetadata{ |
725 | 724 | ID: "foobaz", |
726 | 725 | Name: "foobar's foo org", |
@@ -825,7 +824,7 @@ func TestStreamCommandResponse(t *testing.T) { |
825 | 824 | HostID: "foobar", |
826 | 825 | Counter: 1, |
827 | 826 | Config: cfg, |
828 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 827 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
829 | 828 | Organization: message.HostOrgMetadata{ |
830 | 829 | ID: "foobaz", |
831 | 830 | Name: "foobar's foo org", |
@@ -951,7 +950,7 @@ func TestReauthenticate(t *testing.T) { |
951 | 950 | HostID: "foobar", |
952 | 951 | Counter: 1, |
953 | 952 | Config: cfg, |
954 | | - TrustedKeys: marshalCAPublicKey(ca.Curve(), ca.PublicKey()), |
| 953 | + TrustedKeys: ca.MarshalPublicKeyPEM(), |
955 | 954 | Organization: message.HostOrgMetadata{ |
956 | 955 | ID: "foobaz", |
957 | 956 | Name: "foobar's foo org", |
@@ -1062,17 +1061,6 @@ func TestOverrideTimeout(t *testing.T) { |
1062 | 1061 | require.ErrorIs(t, err, context.DeadlineExceeded) |
1063 | 1062 | } |
1064 | 1063 |
|
1065 | | -func marshalCAPublicKey(curve cert.Curve, pubkey []byte) []byte { |
1066 | | - switch curve { |
1067 | | - case cert.Curve_CURVE25519: |
1068 | | - return pem.EncodeToMemory(&pem.Block{Type: keys.NebulaEd25519PublicKeyBanner, Bytes: pubkey}) |
1069 | | - case cert.Curve_P256: |
1070 | | - return pem.EncodeToMemory(&pem.Block{Type: keys.NebulaECDSAP256PublicKeyBanner, Bytes: pubkey}) |
1071 | | - default: |
1072 | | - panic("unsupported curve") |
1073 | | - } |
1074 | | -} |
1075 | | - |
1076 | 1064 | func TestGetOidcPollCode(t *testing.T) { |
1077 | 1065 | t.Parallel() |
1078 | 1066 |
|
@@ -1219,7 +1207,6 @@ func TestDownloads(t *testing.T) { |
1219 | 1207 | } |
1220 | 1208 |
|
1221 | 1209 | func TestNebulaPemBanners(t *testing.T) { |
1222 | | - t.SkipNow() //todo this is correct for 25519 but not p256. Once this test passes, we can lean on Nebula's implementations. |
1223 | 1210 | const NebulaECDSAP256PublicKeyBanner = "NEBULA ECDSA P256 PUBLIC KEY" |
1224 | 1211 | const NebulaEd25519PublicKeyBanner = "NEBULA ED25519 PUBLIC KEY" |
1225 | 1212 | ca, _ := dnapitest.NebulaCACert() |
|
0 commit comments