outposts/proxy: fix insecure TLS Skip

closes #882

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-14 11:38:40 +02:00
parent 9bdd6f23a4
commit 965db6eaf5
2 changed files with 11 additions and 6 deletions

View File

@ -80,19 +80,19 @@ func (pb *providerBundle) prepareOpts(provider *models.ProxyOutpostConfig) *opti
ID: "default", ID: "default",
URI: provider.InternalHost, URI: provider.InternalHost,
Path: "/", Path: "/",
InsecureSkipTLSVerify: provider.InternalHostSslValidation, InsecureSkipTLSVerify: !provider.InternalHostSslValidation,
}, },
} }
} }
if provider.Certificate != nil { if provider.Certificate != nil {
pb.log.WithField("provider", provider.ClientID).Debug("Enabling TLS") pb.log.WithField("provider", provider.Name).Debug("Enabling TLS")
cert, err := pb.s.ak.Client.Crypto.CryptoCertificatekeypairsViewCertificate(&crypto.CryptoCertificatekeypairsViewCertificateParams{ cert, err := pb.s.ak.Client.Crypto.CryptoCertificatekeypairsViewCertificate(&crypto.CryptoCertificatekeypairsViewCertificateParams{
Context: context.Background(), Context: context.Background(),
KpUUID: *provider.Certificate, KpUUID: *provider.Certificate,
}, pb.s.ak.Auth) }, pb.s.ak.Auth)
if err != nil { if err != nil {
pb.log.WithField("provider", provider.ClientID).WithError(err).Warning("Failed to fetch certificate") pb.log.WithField("provider", provider.Name).WithError(err).Warning("Failed to fetch certificate")
return providerOpts return providerOpts
} }
key, err := pb.s.ak.Client.Crypto.CryptoCertificatekeypairsViewPrivateKey(&crypto.CryptoCertificatekeypairsViewPrivateKeyParams{ key, err := pb.s.ak.Client.Crypto.CryptoCertificatekeypairsViewPrivateKey(&crypto.CryptoCertificatekeypairsViewPrivateKeyParams{
@ -100,17 +100,17 @@ func (pb *providerBundle) prepareOpts(provider *models.ProxyOutpostConfig) *opti
KpUUID: *provider.Certificate, KpUUID: *provider.Certificate,
}, pb.s.ak.Auth) }, pb.s.ak.Auth)
if err != nil { if err != nil {
pb.log.WithField("provider", provider.ClientID).WithError(err).Warning("Failed to fetch private key") pb.log.WithField("provider", provider.Name).WithError(err).Warning("Failed to fetch private key")
return providerOpts return providerOpts
} }
x509cert, err := tls.X509KeyPair([]byte(cert.Payload.Data), []byte(key.Payload.Data)) x509cert, err := tls.X509KeyPair([]byte(cert.Payload.Data), []byte(key.Payload.Data))
if err != nil { if err != nil {
pb.log.WithField("provider", provider.ClientID).WithError(err).Warning("Failed to parse certificate") pb.log.WithField("provider", provider.Name).WithError(err).Warning("Failed to parse certificate")
return providerOpts return providerOpts
} }
pb.cert = &x509cert pb.cert = &x509cert
pb.log.WithField("provider", provider.ClientID).Debug("Loaded certificates") pb.log.WithField("provider", provider.Name).Debug("Loaded certificates")
} }
return providerOpts return providerOpts
} }

View File

@ -531,6 +531,11 @@ paths:
description: '' description: ''
required: false required: false
type: string type: string
- name: ordering
in: query
description: Which field to use when ordering the results.
required: false
type: string
- name: search - name: search
in: query in: query
description: A search term. description: A search term.