|
@@ -73,7 +73,7 @@ func Test_printCert(t *testing.T) {
|
|
tf.Truncate(0)
|
|
tf.Truncate(0)
|
|
tf.Seek(0, 0)
|
|
tf.Seek(0, 0)
|
|
ca, caKey := NewTestCaCert("test ca", nil, nil, time.Time{}, time.Time{}, nil, nil, nil)
|
|
ca, caKey := NewTestCaCert("test ca", nil, nil, time.Time{}, time.Time{}, nil, nil, nil)
|
|
- c, _ := NewTestCert(ca, caKey, "test", time.Time{}, time.Time{}, nil, nil, []string{"hi"})
|
|
|
|
|
|
+ c, _ := NewTestCert(ca, caKey, "test", time.Time{}, time.Time{}, []netip.Prefix{netip.MustParsePrefix("10.0.0.123/8")}, nil, []string{"hi"})
|
|
|
|
|
|
p, _ := c.MarshalPEM()
|
|
p, _ := c.MarshalPEM()
|
|
tf.Write(p)
|
|
tf.Write(p)
|
|
@@ -97,7 +97,9 @@ func Test_printCert(t *testing.T) {
|
|
"isCa": false,
|
|
"isCa": false,
|
|
"issuer": "`+c.Issuer()+`",
|
|
"issuer": "`+c.Issuer()+`",
|
|
"name": "test",
|
|
"name": "test",
|
|
- "networks": [],
|
|
|
|
|
|
+ "networks": [
|
|
|
|
+ "10.0.0.123/8"
|
|
|
|
+ ],
|
|
"notAfter": "0001-01-01T00:00:00Z",
|
|
"notAfter": "0001-01-01T00:00:00Z",
|
|
"notBefore": "0001-01-01T00:00:00Z",
|
|
"notBefore": "0001-01-01T00:00:00Z",
|
|
"publicKey": "`+pk+`",
|
|
"publicKey": "`+pk+`",
|
|
@@ -116,7 +118,9 @@ func Test_printCert(t *testing.T) {
|
|
"isCa": false,
|
|
"isCa": false,
|
|
"issuer": "`+c.Issuer()+`",
|
|
"issuer": "`+c.Issuer()+`",
|
|
"name": "test",
|
|
"name": "test",
|
|
- "networks": [],
|
|
|
|
|
|
+ "networks": [
|
|
|
|
+ "10.0.0.123/8"
|
|
|
|
+ ],
|
|
"notAfter": "0001-01-01T00:00:00Z",
|
|
"notAfter": "0001-01-01T00:00:00Z",
|
|
"notBefore": "0001-01-01T00:00:00Z",
|
|
"notBefore": "0001-01-01T00:00:00Z",
|
|
"publicKey": "`+pk+`",
|
|
"publicKey": "`+pk+`",
|
|
@@ -135,7 +139,9 @@ func Test_printCert(t *testing.T) {
|
|
"isCa": false,
|
|
"isCa": false,
|
|
"issuer": "`+c.Issuer()+`",
|
|
"issuer": "`+c.Issuer()+`",
|
|
"name": "test",
|
|
"name": "test",
|
|
- "networks": [],
|
|
|
|
|
|
+ "networks": [
|
|
|
|
+ "10.0.0.123/8"
|
|
|
|
+ ],
|
|
"notAfter": "0001-01-01T00:00:00Z",
|
|
"notAfter": "0001-01-01T00:00:00Z",
|
|
"notBefore": "0001-01-01T00:00:00Z",
|
|
"notBefore": "0001-01-01T00:00:00Z",
|
|
"publicKey": "`+pk+`",
|
|
"publicKey": "`+pk+`",
|
|
@@ -166,7 +172,7 @@ func Test_printCert(t *testing.T) {
|
|
assert.Nil(t, err)
|
|
assert.Nil(t, err)
|
|
assert.Equal(
|
|
assert.Equal(
|
|
t,
|
|
t,
|
|
- `[{"details":{"curve":"CURVE25519","groups":["hi"],"isCa":false,"issuer":"`+c.Issuer()+`","name":"test","networks":[],"notAfter":"0001-01-01T00:00:00Z","notBefore":"0001-01-01T00:00:00Z","publicKey":"`+pk+`","unsafeNetworks":[]},"fingerprint":"`+fp+`","signature":"`+sig+`","version":1},{"details":{"curve":"CURVE25519","groups":["hi"],"isCa":false,"issuer":"`+c.Issuer()+`","name":"test","networks":[],"notAfter":"0001-01-01T00:00:00Z","notBefore":"0001-01-01T00:00:00Z","publicKey":"`+pk+`","unsafeNetworks":[]},"fingerprint":"`+fp+`","signature":"`+sig+`","version":1},{"details":{"curve":"CURVE25519","groups":["hi"],"isCa":false,"issuer":"`+c.Issuer()+`","name":"test","networks":[],"notAfter":"0001-01-01T00:00:00Z","notBefore":"0001-01-01T00:00:00Z","publicKey":"`+pk+`","unsafeNetworks":[]},"fingerprint":"`+fp+`","signature":"`+sig+`","version":1}]
|
|
|
|
|
|
+ `[{"details":{"curve":"CURVE25519","groups":["hi"],"isCa":false,"issuer":"`+c.Issuer()+`","name":"test","networks":["10.0.0.123/8"],"notAfter":"0001-01-01T00:00:00Z","notBefore":"0001-01-01T00:00:00Z","publicKey":"`+pk+`","unsafeNetworks":[]},"fingerprint":"`+fp+`","signature":"`+sig+`","version":1},{"details":{"curve":"CURVE25519","groups":["hi"],"isCa":false,"issuer":"`+c.Issuer()+`","name":"test","networks":["10.0.0.123/8"],"notAfter":"0001-01-01T00:00:00Z","notBefore":"0001-01-01T00:00:00Z","publicKey":"`+pk+`","unsafeNetworks":[]},"fingerprint":"`+fp+`","signature":"`+sig+`","version":1},{"details":{"curve":"CURVE25519","groups":["hi"],"isCa":false,"issuer":"`+c.Issuer()+`","name":"test","networks":["10.0.0.123/8"],"notAfter":"0001-01-01T00:00:00Z","notBefore":"0001-01-01T00:00:00Z","publicKey":"`+pk+`","unsafeNetworks":[]},"fingerprint":"`+fp+`","signature":"`+sig+`","version":1}]
|
|
`,
|
|
`,
|
|
ob.String(),
|
|
ob.String(),
|
|
)
|
|
)
|
|
@@ -212,6 +218,10 @@ func NewTestCert(ca cert.Certificate, signerKey []byte, name string, before, aft
|
|
after = ca.NotAfter()
|
|
after = ca.NotAfter()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if len(networks) == 0 {
|
|
|
|
+ networks = []netip.Prefix{netip.MustParsePrefix("10.0.0.123/8")}
|
|
|
|
+ }
|
|
|
|
+
|
|
pub, rawPriv := x25519Keypair()
|
|
pub, rawPriv := x25519Keypair()
|
|
nc := &cert.TBSCertificate{
|
|
nc := &cert.TBSCertificate{
|
|
Version: cert.Version1,
|
|
Version: cert.Version1,
|