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

Export pfx from secret as tls #174

Merged
merged 2 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cmd/azure-keyvault-controller/controller/secret_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package controller

import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"
Expand Down Expand Up @@ -129,6 +130,22 @@ func (h *azureSecretHandler) HandleSecret() (map[string][]byte, error) {
case corev1.SecretTypeSSHAuth:
values[corev1.SSHAuthPrivateKey] = []byte(secret)

case corev1.SecretTypeTLS:
pfxRaw, err := base64.StdEncoding.DecodeString(secret)
if err != nil {
return nil, fmt.Errorf("Failed to decode base64 encoded secret, error: %+v", err)
}
cert, err := vault.NewCertificateFromPfx(pfxRaw, h.secretSpec.Spec.Output.Secret.ChainOrder == "ensureserverfirst")
if err != nil {
return nil, fmt.Errorf("Error while processing secret content as pfx, error: %+v", err)
}
if values[corev1.TLSCertKey], err = cert.ExportPublicKeyAsPem(); err != nil {
return nil, fmt.Errorf("Error exporting public key, error: %+v", err)
}
if values[corev1.TLSPrivateKeyKey], err = cert.ExportPrivateKeyAsPem(); err != nil {
return nil, fmt.Errorf("Error exporting private key, error: %+v", err)
}

default:
if h.secretSpec.Spec.Vault.Object.Type != akv.AzureKeyVaultObjectTypeMultiKeyValueSecret &&
h.secretSpec.Spec.Output.Secret.DataKey == "" {
Expand Down
30 changes: 30 additions & 0 deletions cmd/azure-keyvault-controller/controller/secret_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
var (
pemCert = "-----BEGIN PRIVAT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RYwgzhTqDWoIFB7JDiUAbkwZn4d/rSpZ7MxXt67QiS98ja8WvGfm\nijGb0hgKOrutGc+MCEDquWUqThnD0Q14cBdcb/gw3sSfhNamH00aKgNsQtekqbM6iljuyQT9hQD5\n4JkPiNEBWYfyTVQRkM4QB6RO28m0+EeKxVS3vovvVvyJMqUuTurIeqiS8LZLzMZ381L88SPeaoOX\nv/2QlUmg2W4MY6gxLjSCr1TVtt22nUTBZVyl1olHv2Et1I5NI2BFVaM8k5tGgMvIy4iFBTsT/1xi\nUm8UUWN1eq3oEcoUCFbIcmfNGQ1PB/qJCjDanbk5dEu1gm8fCzOUIcOxmXTYMTJGCerArdKakxQG\nJDy7kycYbZ81x+8Aqya2fJ1zsngskN7gfjZVNnh6GOjArV0BNka5swXAdxc3wggxJTAjBgkqhkiG\n9w0BCRUxFgQUCa7CXwL4Np3Fc5ojjCjfH4J15XAwMTAhMAkGBSsOAwIaBQAEFIso6r8qXcfkJp14\nliTAWf5P52EgBAhjHqtjwlzsUQICCAA="
)

type fakeVaultService struct {
Expand Down Expand Up @@ -379,3 +380,32 @@ func TestHandleSecretWithSSHAuthAsOutput(t *testing.T) {
t.Errorf("there should be a value stored for key '%s'", corev1.SSHAuthPrivateKey)
}
}

func TestHandleSecretWithTypeTLSAsOutput(t *testing.T) {
fakeVault := &fakeVaultService{
fakeSecretValue: pfxCert,
}

secret := secret()
secret.Spec.Vault.Object.Type = "secret"
secret.Spec.Output.Secret.Type = corev1.SecretTypeTLS

transformator, err := transformers.CreateTransformator(&secret.Spec.Output)
handler := NewAzureSecretHandler(secret, fakeVault, *transformator)
values, err := handler.HandleSecret()
if err != nil {
t.Error(err)
}
if values == nil {
t.Error("handler should have returned values")
}
if len(values) != 2 {
t.Error("there should be exactly two key/value pairs present")
}
if values[corev1.TLSCertKey] == nil {
t.Errorf("there should be a value stored for key '%s'", corev1.TLSCertKey)
}
if values[corev1.TLSPrivateKeyKey] == nil {
t.Errorf("there should be a value stored for key '%s'", corev1.TLSPrivateKeyKey)
}
}