lego: infoblox: `tls: handshake failure`

Welcome

  • Yes, I’m using a binary release within 2 latest releases.
  • Yes, I’ve searched similar issues on GitHub and didn’t find any.
  • Yes, I’ve included all information below (version, config, etc).

What did you expect to see?

I wanted to request a certificate from Let’sEncrypt via infoblox.

Obtaining certificates that way should work, as we successfully could do with certbot (+ a plugin for infoblox) and acme.sh.

What did you see instead?

Running lego fails with remote error: tls: handshake failure when connecting to Infoblox WAPI.

We suspect this is due to (the configuration of) the Go TLS client - as connecting to the same server works flawlessly with a browser and also certbot and acme.sh successfully made the WAPI requests.

We tried to trace the issue with tcpdump and Wireshark and found that the connection is directly terminated with a TLS Fatal Alert Handshake Failure (40) by the server, after lego’s TLS client sent the TLS ClientHello. For us, it seems that the set of TLS cipher suites of lego’s TLS client and the server have no overlap, so that no connection is possible. If we leverage the bare Go TLS client independently of lego and allow all possible cipher suites instead of the default ones, we can successfully open a TLS connection to the Infoblox WAPI server.

(This issue might be related to #1099. However, we verified that the issue is not due to a mismatch of TLS versions on client and server.)

Is there some option to setup cipher suites manually for lego? (In our situation, we cannot change the cipher suites that are used on the Infoblox server, as it is not under our direct control.)

How do you use lego?

Binary

Reproduction steps

LEGO_DEBUG_CLIENT_VERBOSE_ERROR=true \
INFOBLOX_USERNAME=user \
INFOBLOX_PASSWORD=pass \
INFOBLOX_HOST=infoblox.example.com \
INFOBLOX_DNS_VIEW=Extern INFOBLOX_WAPI_VERSION=2.12 \
./lego --accept-tos --email="admin@my-domain.com" --dns infoblox -d 'vm.my-domain.com' run

Effective version of lego

lego version 4.22.2 linux/amd64

Logs

root@vm:~/lego# LEGO_DEBUG_CLIENT_VERBOSE_ERROR=true \
INFOBLOX_USERNAME=user INFOBLOX_PASSWORD=pass \
INFOBLOX_HOST=infoblox.example.com \
INFOBLOX_DNS_VIEW=Extern INFOBLOX_WAPI_VERSION=2.12 \
./lego --accept-tos --email="admin@my-domain.com" --dns infoblox -d 'vm.my-domain.com' run
2025/02/26 14:02:36 No key found for account admin@my-domain.com. Generating a P256 key.
2025/02/26 14:02:36 Saved key to /root/lego/.lego/accounts/acme-v02.api.letsencrypt.org/admin@my-domain.com/keys/admin@my-domain.com.key
2025/02/26 14:02:36 [INFO] acme: Registering account for admin@my-domain.com
!!!! HEADS UP !!!!

Your account credentials have been saved in your
configuration directory at "/root/lego/.lego/accounts".

You should make a secure backup of this folder now. This
configuration directory will also contain certificates and
private keys obtained from the ACME server so making regular
backups of this folder is ideal.
2025/02/26 14:02:36 [INFO] [vm.my-domain.com] acme: Obtaining bundled SAN certificate
2025/02/26 14:02:37 [INFO] [vm.my-domain.com] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz/2251150175/481782810705
2025/02/26 14:02:37 [INFO] [vm.my-domain.com] acme: Could not find solver for: tls-alpn-01
2025/02/26 14:02:37 [INFO] [vm.my-domain.com] acme: Could not find solver for: http-01
2025/02/26 14:02:37 [INFO] [vm.my-domain.com] acme: use dns-01 solver
2025/02/26 14:02:37 [INFO] [vm.my-domain.com] acme: Preparing to solve DNS-01
2025/02/26 14:02:37 Cannot unmarshall to check empty value '', err: 'unexpected end of JSON input'
2025/02/26 14:02:37 GetObject request error: 'Get "https://infoblox.example.com:443/wapi/v2.12/userprofile?_proxy_search=GM&_return_fields=name": remote error: tls: handshake failure'
2025/02/26 14:02:37 Failed to connect to the Grid, err: Get "https://infoblox.example.com:443/wapi/v2.12/userprofile?_proxy_search=GM&_return_fields=name": remote error: tls: handshake failure 
2025/02/26 14:02:37 [INFO] [vm.my-domain.com] acme: Cleaning DNS-01 challenge
2025/02/26 14:02:37 Cannot unmarshall to check empty value '', err: 'unexpected end of JSON input'
2025/02/26 14:02:37 GetObject request error: 'Get "https://infoblox.example.com:443/wapi/v2.12/userprofile?_proxy_search=GM&_return_fields=name": remote error: tls: handshake failure'
2025/02/26 14:02:37 Failed to connect to the Grid, err: Get "https://infoblox.example.com:443/wapi/v2.12/userprofile?_proxy_search=GM&_return_fields=name": remote error: tls: handshake failure 
2025/02/26 14:02:37 [WARN] [vm.my-domain.com] acme: cleaning up failed: infoblox: Get "https://infoblox.example.com:443/wapi/v2.12/userprofile?_proxy_search=GM&_return_fields=name": remote error: tls: handshake failure 
2025/02/26 14:02:37 [INFO] Deactivating auth: https://acme-v02.api.letsencrypt.org/acme/authz/2251150175/481782810705
2025/02/26 14:02:37 Could not obtain certificates:
	error: one or more domains had a problem:
[vm.my-domain.com] [vm.my-domain.com] acme: error presenting token: infoblox: Get "https://infoblox.example.com:443/wapi/v2.12/userprofile?_proxy_search=GM&_return_fields=name": remote error: tls: handshake failure

Go environment (if applicable)

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

We found a solution in the Go 1.22 Release Notes:

By default, cipher suites without ECDHE support are no longer offered by either clients or servers during pre-TLS 1.3 handshakes. This change can be reverted with the tlsrsakex=1 GODEBUG setting.

Setting the environment variable GODEBUG=tlsrsakex=1 results in a successful TLS connection.

there is a problem with this server that can be important.

Regarding “our” Infoblox WAPI server, we contacted the administrator to inform them about potential cipher suite issues.

I consider the problem as “fixed”, so I close the issue.

@ldez Agreed that the Lego binary was built with Go 1.24. It sounds like klmmr also wrote a small Go program independent of Lego and used it successfully to make an HTTPS request to the server. I’m wondering what version of Go they used for that independent program.

Sorry if I added any confusion dropping in randomly:-)

Hi, we used the following go version: go version go1.24.0 linux/amd64

Without specifying any cipher suites, the connection fails with the aforementioned handshake failure. This is the source code we used to establish a connection, i.e. we added all possible cipher suites from the documentation:


package main

import (
	"crypto/tls"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func main() {
	// The server you want to connect to
	url := "https://infoblox.example.com"

	cipherSuites := []uint16{
		// Add other desired cipher suites here
		tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_RSA_WITH_RC4_128_SHA,
		tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
		tls.TLS_RSA_WITH_AES_128_CBC_SHA,
		tls.TLS_RSA_WITH_AES_256_CBC_SHA,
		tls.TLS_RSA_WITH_AES_128_CBC_SHA256,
		tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
		tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
		tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
		tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA,
		tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
		tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
		tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
		tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
		tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
		tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
		tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
		tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
		tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
	}
	// Set up a custom TLS configuration (optional)
	tlsConfig := &tls.Config{
		CipherSuites: cipherSuites,
	}

	// Create an HTTP client with a custom TLS configuration
	client := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: tlsConfig,
		},
	}

	// Send an HTTP GET request to the server
	resp, err := client.Get(url)
	if err != nil {
		log.Fatalf("Error sending request: %v", err)
	}
	defer resp.Body.Close()

	// Read and print the response body
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatalf("Error reading response body: %v", err)
	}

	// Print the status code and the response body
	fmt.Printf("Response Status: %s\n", resp.Status)
	fmt.Printf("Response Body:\n%s\n", body)
}

The specific reason I’m asking is that Go 1.24 added X25519MLKEM768 key exchange, and the release notes mention:

The new post-quantum X25519MLKEM768 key exchange mechanism is now supported and is enabled by default when Config.CurvePreferences is nil. GODEBUG setting tlsmlkem=0 reverts the default. This can be useful when dealing with buggy TLS servers that do not handle large records correctly, causing a timeout during the handshake (see TLS post-quantum TL;DR fail).

The reported issue smells a bit like this issue to me. If the user’s succesful independent test was using Go 1.23 that would be further evidence.

Sorry, I read your message too quickly.

@ldez Agreed that the Lego binary was built with Go 1.24. It sounds like klmmr also wrote a small Go program independent of Lego and used it successfully to make an HTTPS request to the server. I’m wondering what version of Go they used for that independent program.

Sorry if I added any confusion dropping in randomly:-)