mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-19 20:17:30 +02:00
config: update logic for checking overlapping certificates (#4216)
* config: update logic for checking overlapping certificates * add test * go mod tidy
This commit is contained in:
parent
3a791542d4
commit
baf964f44a
10 changed files with 216 additions and 138 deletions
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
|
@ -735,13 +736,17 @@ func TestOptions_ApplySettings(t *testing.T) {
|
|||
cert3, err := cryptutil.GenerateCertificate(nil, "not.example.com")
|
||||
require.NoError(t, err)
|
||||
|
||||
certsIndex := cryptutil.NewCertificatesIndex()
|
||||
xc1, _ := x509.ParseCertificate(cert1.Certificate[0])
|
||||
certsIndex.Add(xc1)
|
||||
|
||||
settings := &config.Settings{
|
||||
Certificates: []*config.Settings_Certificate{
|
||||
{CertBytes: encodeCert(cert2)},
|
||||
{CertBytes: encodeCert(cert3)},
|
||||
},
|
||||
}
|
||||
options.ApplySettings(ctx, settings)
|
||||
options.ApplySettings(ctx, certsIndex, settings)
|
||||
assert.Len(t, options.CertificateFiles, 2, "should prevent adding duplicate certificates")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue