Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple secrets load is failing #5

Open
rbasukala opened this issue Dec 7, 2022 · 0 comments
Open

Multiple secrets load is failing #5

rbasukala opened this issue Dec 7, 2022 · 0 comments

Comments

@rbasukala
Copy link

rbasukala commented Dec 7, 2022

I am trying to load multiple certs as below:

certDomains = []string{"www.example.com", "www.hello.com"}

s := []types.Resource{}

for _, cd := range certDomains {
		s = append(s, MakeSecret(cd))
}

resources[resource.SecretType] = s

// Secrets
func MakeSecret(vhost string) *envoy_api_v3_auth.Secret {
	var secretName = strings.Replace(vhost, ".", "_", -1)
	priv, err := ioutil.ReadFile("certs/" + secretName + ".key")
	if err != nil {
		log.Fatal(err)
	}
	pub, err := ioutil.ReadFile("certs/" + secretName + ".cert")
	if err != nil {
		log.Fatal(err)
	}
	log.Infof(">>>>>>>>>>>>>>>>>>> creating Secret " + secretName)
	return &envoy_api_v3_auth.Secret{
		Name: secretName,
		Type: &envoy_api_v3_auth.Secret_TlsCertificate{
			TlsCertificate: &envoy_api_v3_auth.TlsCertificate{
				CertificateChain: &core.DataSource{
					Specifier: &core.DataSource_InlineBytes{InlineBytes: []byte(pub)},
				},
				PrivateKey: &core.DataSource{
					Specifier: &core.DataSource_InlineBytes{InlineBytes: []byte(priv)},
				},
			},
		},
	}
}

With certDomains being one element it works. I am trying to load multiple secrets with adding more elements on the list and it stops working, no error in console. Envoy shows certificate is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant