mirror of https://github.com/hashicorp/consul
Backport of connect: strip port from DNS SANs for ingress gateway leaf cert into release/1.14.x (#15354)
This pull request was automerged via backport-assistantpull/15357/head
parent
a6f4893f5a
commit
904aaf742d
@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
connect: strip port from DNS SANs for ingress gateway leaf certificate to avoid an invalid hostname error when using the Vault provider.
|
||||||
|
```
|
@ -0,0 +1,36 @@
|
|||||||
|
package connect
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateCSR_FormatDNSSANs(t *testing.T) {
|
||||||
|
pk, _, err := GeneratePrivateKey()
|
||||||
|
require.NoError(t, err)
|
||||||
|
spiffeID := &SpiffeIDService{
|
||||||
|
Host: "7528f42f-92e5-4db4-b84c-3405c3ca91e6",
|
||||||
|
Service: "srv1",
|
||||||
|
Datacenter: "dc1",
|
||||||
|
}
|
||||||
|
csr, err := CreateCSR(spiffeID, pk, []string{
|
||||||
|
"foo.example.com",
|
||||||
|
"foo.example.com:8080",
|
||||||
|
"bar.example.com",
|
||||||
|
"*.example.com",
|
||||||
|
":8080",
|
||||||
|
"",
|
||||||
|
}, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
req, err := ParseCSR(csr)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, req.URIs, 1)
|
||||||
|
require.Equal(t, spiffeID.URI(), req.URIs[0])
|
||||||
|
require.Equal(t, []string{
|
||||||
|
"foo.example.com",
|
||||||
|
"bar.example.com",
|
||||||
|
"*.example.com",
|
||||||
|
}, req.DNSNames)
|
||||||
|
}
|
Loading…
Reference in new issue