-
Notifications
You must be signed in to change notification settings - Fork 21
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
Error with certificates trying to retrieve a secret #176
Comments
I don't know if this behavior is intentional, it seems a little strange having to specify the entire certificate chain bundle... In fact, it seems strange and a bit unconventional having to specify a public SSL certificate at all 🤔 The same problem occurred (and was bypassed) in the same way in the conjur-puppet module as well (see this issue). |
Hi @R3DRUN3, Are you using a self-signed certificate? Can you please post the values of your loaded config? |
Hi @szh, -----BEGIN CERTIFICATE-----
MIID0DCCArigAwIBAgIUeO2/+zmaBjmfJRxB1bwzM93lnmAwDQYJKoZIhvcNAQEL
BQAwUTEQMA4GA1UECgwHZGVmYXVsdDESMBAGA1UECwwJQ29uanVyIENBMSkwJwYD
VQQDDCBjb25qdXItbGIudnNwaGVyZS5wbGF5Z3JvdW5kLmNvbTAeFw0yMzAxMTAx
MTI3MzRaFw0zMzAxMDcxMTI3MzRaMCsxKTAnBgNVBAMMIGNvbmp1ci1sYi52c3Bo
ZXJlLnBsYXlncm91bmQuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAvP11Ad8F8rVQXGrvhqv4yBhCLW+E85KnNV9TjNiV0fojrQMNHTIWwY5TL8vL
kTohi6NTHPZCBu6ig1sAwlvwF72oHrjDITN7YUxUcgCAuQzEG4lK2cPNWkmsMlaZ
e9ECJguvIh1QF+TW+72CIESR9IQeQKuPwZis7VBqbInQboiYHb849xVWIpzdQH2D
4IGhknuZQCUUOYbtpp1aJOJnQvEwFZ2hwzlK2i63JA18SafPHxt91r4TC9Jih3wN
CriL/TtFaz9/n0CQM1HETpt3B00aRom6QI6dnqixACJ2fuNqyiqnn53c7HiLWCvQ
/vJ46CTGxOKeae+sBeDjGrjTkQIDAQABo4HFMIHCMA4GA1UdDwEB/wQEAwIFoDAd
BgNVHQ4EFgQ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ZUkS1GEagoeuiciRUi5GvU1jJAMgxHy
wlb5/fMBZSNGpDaqg2xTVQC98flvNCW8zrqAq40OhvaR5wqkoEo9nL1jMHd4X3Oq
ZOvLNFbLaWVsEI0eBG00nB+71ykorZllbBQp2BLM+eLYQEvpZRXsQB8rsWOavI2y
jkwcRp9ZreoZ/FMcbfxE+vkclI8g5egag2NQd1eYznXvJtG44OhgReqzpeIZ/sYd
1u9sUPqOiEg1Wktfwp4/FrRvKBTzLvLNQ0fQrlKwPxu8tH0kxgTSbYl4EKo78wID
AQABo4HxMIHuMIGQBgNVHREEgYgwgYWCIGNvbmp1ci1sYi52c3BoZXJlLnBsYXln
cm91bmQuY29tgh9jb25qdXItMS52c3BoZXJlLnBsYXlncm91bmQuY29tgh9jb25q
dXItMi52c3BoZXJlLnBsYXlncm91bmQuY29tgh9jb25qdXItMy52c3BoZXJlLnBs
YXlncm91bmQuY29tMB0GA1UdDgQWBBRIYp17facC6wS8ZgHvrraX9oOmrDAfBgNV
HSMEGDAWgBRIYp17facC6wS8ZgHvrraX9oOmrDAMBgNVHRMEBTADAQH/MAsGA1Ud
DwQEAwIB5jANBgkqhkiG9w0BAQsFAAOCAQEASnn8uqBALs8Lo52PU/ANHgH95bKc
fO9ejmeW7iQrPXXW0GMdisJQJUdRpptmC9tQiAvOP51Qa3kIhVkFky9/VD9EepwS
jnJ+87W1/nGx2RyQQsOnjomd2RZe9sftrL3kpdK/e4tOoxpJl/w2lz8WTzqupBew
ZBocoP91IcmLAu9nPOtWY7mEFvWWR8ZVcQIeWbZymJqqv2HBs07u12mcfRLP9KK+
sb/HlYxV8TBF3LtrFUEIfk4OaFJEI7iHqh3Dnpu+6NR/f96nf/uuDOhJk8KQ11Rd
U+1yG164iUDUNMofkO2n2/URlm9ytAIENrzG7A+k2RWqlhdb0yApTlR2VQ==
-----END CERTIFICATE----- I saved this in a file called #!/bin/bash
export CONJUR_APPLIANCE_URL="https://10.7.0.122"
export CONJUR_ACCOUNT="default"
export CONJUR_AUTHN_LOGIN="host/conjur/tekton-pipeline-demo"
export CONJUR_AUTHN_API_KEY="<conjur-api-key-here>"
export CONJUR_CERT_FILE="conjur"
go run main.go |
I'll take some time tomorrow to try to reproduce |
I haven't been able to reproduce this yet |
Please try validating the connection by running a |
@doodlesbykumbi already done it. #!/bin/bash
echo "Retrieving secret from Conjur..."
TOKEN=$(curl -s --insecure -X POST --header "Accept-Encoding: base64" --data <API-KEY-HERE> https://10.7.0.122/authn/default/host%2Fconjur%2Ftekton-pipeline-demo/authenticate)
SECRET=$(curl -s --insecure -H "Authorization: Token token=\"$TOKEN\"" https://10.7.0.120/secrets/default/variable/secrets%2FTEST-VARIABLE-TEKTON-PIPELINE)
echo "The secret value is: $SECRET" |
Let's try and isolate this issue from Try replace your // main.go
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"log"
"net/http"
"net/http/httputil"
"time"
"github.com/cyberark/conjur-api-go/conjurapi"
)
func main() {
config, err := conjurapi.LoadConfig()
if err != nil {
log.Fatal(err)
}
cert, err := config.ReadSSLCert()
if err != nil {
log.Fatal(err)
}
httpClient, err := newHTTPSClient(cert)
if err != nil {
log.Fatal(err)
}
if err != nil {
// Handle error
fmt.Println("Error creating HTTP client:", err)
return
}
resp, err := httpClient.Get(config.ApplianceURL)
if err != nil {
// Handle error
fmt.Println("Error making GET request:", err)
return
}
defer resp.Body.Close()
dump, err := httputil.DumpResponse(resp, true)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", dump)
// Process the response
// ...
}
func newHTTPSClient(cert []byte) (*http.Client, error) {
pool := x509.NewCertPool()
ok := pool.AppendCertsFromPEM(cert)
if !ok {
return nil, fmt.Errorf("Can't append Conjur SSL cert")
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{RootCAs: pool},
}
return &http.Client{Transport: tr, Timeout: time.Second * 10}, nil
} |
I will close this issue as I am able to bypass the problem specifying the certificate chain. |
Hey @R3DRUN3. Thanks for closing the issue but I would appreciate if you can test out the code from the previous comment. It would help us to figure out if the issue is related to code we wrote or if its present on the Go HTTP client. |
Summary
When I try to retrieve a secret, I get the following error:
x509: certificate is not standards compliant.
I noticed it may be related to this issue however, even trying from ubuntu, I get a certificate error, albeit a different one:
x509: certificate signed by unknown authority.
Steps to Reproduce
The following is the Go script that I am using:
Expected Results
The program complete the secret retrieval without errors.
Actual Results
See the above errors.
Reproducible
Version/Tag number
go version: go1.20.4 darwin/amd64
library version: github.com/cyberark/conjur-api-go v0.11.0
Environment setup
The script is launched from localhost and the Conjur instance is on a remote VM (connection via VPN).
Additional Information
I get the same error with the terraform conjur provider.
The config env vars are ok: I've succesfully run a bash script with the same values and it works.
It seems that the problem is related to self signed certificates, is there a way to bypass this check?
Thank you.
The text was updated successfully, but these errors were encountered: