When the elastic/beats module is updated from v7.11.2 to v7.17.X elastic-agent encounters a TLS error:
Error: fail to enroll: fail to execute request to fleet-server: remote error: tls: bad certificate
- Copy
transport/tlscommon@main
fromelastic/elastic-agent-libs
tobeats@7.17
and build a new elastic-agent to test with fleet-server built with beats v7.17.18 - Copy
transport/tlscommon@main
and build a new elastic-agent and fleet-server binaries - Copy
transport/tlscommon@main
and build a new elastic-agent and fleet-server binaries, and copy additional lookup logic from agent pr to make sure agent connects to localhost:8221 after installation
- elastic-agent changes including tlscommon update and additional debug info here
- fleet-server chagnes using updated beats (on disk) and debug info here
- build elastic-agent and fleet-server distributables
- copy to VM and unpack, put fleet-server* in the
downloads
dir of elastic-agent - Create 7.17.21-SNAPSHOT deployment in qa
- create new policy with only the fleet-server integration
$ sudo ./elastic-agent install --url=https://192.168.1.21:8220 \
--fleet-server-es=https://d549560f2afd4dada7aec461e08f2866.us-central1.gcp.qa.cld.elstc.co:443 \
--fleet-server-service-token=AAEAAWVsYXN0aWMvZmxlZXQtc2VydmVyL3Rva2VuLTE3MTMzODAxNzMzMjE6Zmx4N0ZwS21SeDY3QmV4M19OLVRaZw \
--fleet-server-policy=05370f80-fcec-11ee-a4e8-3142bce5d69f
Elastic Agent will be installed at /opt/Elastic/Agent and will run as a service. Do you want to continue? [Y/n]:y
2024-04-17T18:56:43.196Z INFO cmd/enroll_cmd.go:390 Generating self-signed certificate for Fleet Server
2024-04-17T18:56:44.969Z INFO cmd/enroll_cmd.go:757 Waiting for Elastic Agent to start
2024-04-17T18:56:46.974Z INFO cmd/enroll_cmd.go:807 Fleet Server - Starting
2024-04-17T18:56:50.981Z INFO cmd/enroll_cmd.go:788 Fleet Server - Running on policy with Fleet Server integration: 05370f80-fcec-11ee-a4e8-3142bce5d69f; missing config fleet.agent.id (expected during bootstrap process), server.ssl: &{Enabled:<nil> VerificationMode:full Versions:[] CipherSuites:[] CAs:[] Certificate:{Certificate:-----BEGIN CERTIFICATE-----
MIIDSjCCAjKgAwIBAgICBn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TQnhxIty6
J5CMyaYEjsTVolXzl8c9mHqJ7NSNMkcvFxrCs/wXLVDS0QqAd2ylk9ebUyFgqJNh
bvxvaDsqSpOoz1Czg21N980iJDcX8Xw9RgzgTRECgYEA12GJLw3HuzYuZCnX76Cp
aX57Y8jcpKGPNe2cPB7R937huq+tSdqD+3LEs+7gXXooKRwu/Fk283m/FhCG+04A
HvUw+yxhdKsof46CZ0gWb29v+7h49E//Byg8Robn7ZHXzbd2+Dfx/KCHcMuFzII6
yctwAIr81EtKWjf2T3f8gC0CgYAlWdamfal8lkpC2veQnYOzpimcYuzxl8Uq5i9S
Jo+4GdEdIgsxrJL5Ha7IClexvIwkJTvdh642guxpr5c44Ml6xfA1UPWdd2HtVkeT
asyxfGFKR/acx6RKAXYsgNBjXxSzpS1qrs63gUqS3CTXWS4Ahtl4mN2D1jGqNFrR
TbRmUQKBgQC/C/7fbqJydxcFb2nDVEsqWhFPnCILER7HYdl18PhAsEzVJfe6uupq
oyBrkDYacZXJCiiJCrEjQ+xhh65BmRj2ji+QXz4W/nFUOWk579GcFS9R6xNWuDNg
nCvkUubiVOTMeaRj3F7ITQ9nBv+j+I9r/P5nq4bbuYBF5+gDjcaqKA==
-----END RSA PRIVATE KEY-----
Passphrase: PassphrasePath:} CurveTypes:[] ClientAuth:<nil> CASha256:[]}, host: 0.0.0.0
2024-04-17T18:56:51.697Z INFO cmd/enroll_cmd.go:458 Starting enrollment to URL: https://fleet-server-dev:8220/
2024-04-17T18:56:51.808Z INFO cmd/enroll_cmd.go:485 Attempting to diagnose tls issues {"host": "fleet-server-dev:8220"}
2024-04-17T18:56:51.813Z INFO cmd/enroll_cmd.go:498 Remote cert found {"issuer_name": "CN=localhost,O=elastic-fleet", "expiry": "2034-April-17", "common_name": "localhost", "dns_names": ["fleet-server-dev"], "ips": null, "issuer": "MCwxFjAUBgNVBAoTDWVsYXN0aWMtZmxlZXQxEjAQBgNVBAMTCWxvY2FsaG9zdA==", "sig": "w+dBENVwgOwg1EgKT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QUHAwIGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE\nFA9p6ec64LyUELzmpPzBAkIQHRklMBQGA1UdEQQNMAuCCWxvY2FsaG9zdDANBgkq\nhkiG9w0BAQsFAAOCAQEAA/IUmaHeJCUmUpV30Rmz1nNX35mSXXpQGdPmvQTYZcJV\nH0EPQwXW+esGYemxoPzMhT2RayYVtRJgFq7E9VlYOAdv3PdegNoiWoBbtA441vTj\nO1Lit/3hC6KLeGSuGLNo3baedxJuk3RVmkqBJm6LHDqDI58ozO6l0s9yczdaTKDh\nvqWiMBupesQdSNlrEhCpAvPbcu5r3WWfEDsaLPAvAJSZrIbzWaMTxJcy4KQYpDuf\n5fkMEgD8BNHBKqdbHTSxSGT4oTrlqtezibGnZ1BnQ25Ot+pxW1E0bD+NH1BFZ2Dl\n1XAvawstapfLwwHZie6rLOLhnaGpjPGeg3e07xA4lA==\n-----END CERTIFICATE-----\n"]}
Error: fail to enroll: fail to execute request to fleet-server: remote error: tls: bad certificate
beats#22495 changes cert verification to require each cert to have at least one SAN entry, but this may not be the issue as the fleet-server reports to have a cert with dns fleet-server-dev
which is the name of the vargant box
Copying the cert, key, and ca to tmp
we can see that the CA signs the cert:
$openssl verify -verbose -CAfile /tmp/ca.crt /tmp/cert.crt
/tmp/cert.crt: OK
sudo ./elastic-agent install \
--url=https://fleet-server-dev:8220 \
--fleet-server-es=https://d549560f2afd4dada7aec461e08f2866.us-central1.gcp.qa.cld.elstc.co:443 \
--fleet-server-service-token=AAEAAWVsYXN0aWMvZmxlZXQtc2VydmVyL3Rva2VuLTE3MTMzODAxNzMzMjE6Zmx4N0ZwS21SeDY3QmV4M19OLVRaZw \
--fleet-server-policy=05370f80-fcec-11ee-a4e8-3142bce5d69f \
--fleet-server-cert=/tmp/cert.crt \
--fleet-server-cert-key=/tmp/key.crt \
--certificate-authorities=/tmp/ca.crt
has the same TLS issues,
adding --insecure
, or replacing --certificate-authorities
with --insecure
also has TLS issues
building an elastic-agent froom the 7.17 branch without any changes and specifing the certs/ca above results in a successful install
building an elastic-agent (from the do-not-backport branch) without the fleet-server changes, and specifing the certs results in a success The issue is with the fleet-server; elastic-agent bootstrapping differences are not a cause
Trying to update the fleet-server beats import to 7.12.0 resulted in the error occuing. Version contains the update to the golang version and other improvements v7.12.0 was the release after v7.11.2 and is where the error was introduced