Skip to content

Commit

Permalink
remove struct use for server_cert/key on root config
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpmartinez committed Jul 13, 2022
1 parent daf51ad commit b9b9706
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
12 changes: 5 additions & 7 deletions chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,11 @@ func Test_Assemble(t *testing.T) {
}))

identityCfg := Config{
Key: "pem:" + keyPem,
Cert: "pem:" + serverPem,
ServerPair: ServerPair{
ServerCert: "pem:" + serverPem,
ServerKey: "pem:" + keyPem,
},
CA: "pem:" + caPem,
Key: "pem:" + keyPem,
Cert: "pem:" + serverPem,
ServerCert: "pem:" + serverPem,
ServerKey: "pem:" + keyPem,
CA: "pem:" + caPem,
}

id, err := LoadIdentity(identityCfg)
Expand Down
3 changes: 2 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const (
type Config struct {
Key string `json:"key" yaml:"key" mapstructure:"key"`
Cert string `json:"cert" yaml:"cert" mapstructure:"cert"`
ServerPair `yaml:",inline"` //contains ServerCert & ServerKey, yaml requires `inline` JSON does not
ServerCert string `json:"server_cert,omitempty" yaml:"server_cert,omitempty" mapstructure:"server_cert,omitempty"`
ServerKey string `json:"server_key,omitempty" yaml:"server_key,omitempty" mapstructure:"server_key,omitempty"`
AltServerCerts []ServerPair `json:"alt_server_certs,omitempty" yaml:"alt_server_certs,omitempty" mapstructure:"alt_server_certs,omitempty"`
CA string `json:"ca,omitempty" yaml:"ca,omitempty" mapstructure:"ca"`
}
Expand Down
10 changes: 4 additions & 6 deletions identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,10 @@ func TestLoadIdentityWithAltServerCerts(t *testing.T) {
}

cfg := Config{
Key: "pem:" + string(pem.EncodeToMemory(childKey1Pem)),
Cert: "pem:" + string(pem.EncodeToMemory(childCert1Pem)) + string(pem.EncodeToMemory(parentPem)),
ServerPair: ServerPair{
ServerKey: "pem:" + string(pem.EncodeToMemory(childKey2Pem)),
ServerCert: "pem:" + string(pem.EncodeToMemory(childCert2Pem)) + string(pem.EncodeToMemory(parentPem)),
},
Key: "pem:" + string(pem.EncodeToMemory(childKey1Pem)),
Cert: "pem:" + string(pem.EncodeToMemory(childCert1Pem)) + string(pem.EncodeToMemory(parentPem)),
ServerKey: "pem:" + string(pem.EncodeToMemory(childKey2Pem)),
ServerCert: "pem:" + string(pem.EncodeToMemory(childCert2Pem)) + string(pem.EncodeToMemory(parentPem)),
AltServerCerts: []ServerPair{
{
ServerKey: "pem:" + string(pem.EncodeToMemory(childKey3Pem)),
Expand Down
10 changes: 4 additions & 6 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ func (i *TokenId) ShallowCloneWithNewToken(token string) *TokenId {

func LoadServerIdentity(clientCertPath, serverCertPath, keyPath, caCertPath string) (*TokenId, error) {
idCfg := Config{
Key: keyPath,
Cert: clientCertPath,
ServerPair: ServerPair{
ServerCert: serverCertPath,
},
CA: caCertPath,
Key: keyPath,
Cert: clientCertPath,
ServerCert: serverCertPath,
CA: caCertPath,
}

if id, err := LoadIdentity(idCfg); err != nil {
Expand Down

0 comments on commit b9b9706

Please sign in to comment.