Golang Autocert: staging environment

First off, my apologies if this is not the place to seek help on this issue. I search golang autocert help & letsencrypt help is top of search results.

I have spent days searching for how configure the golang autocert ACME client to use the Letsencrypt staging environment, even if it is at possible given the sparseness of content if any on this subject.

I have read the docs at [https://pkg.go.dev/golang.org/x/crypto/acme/autocert?tab=doc] and can find no reference on how to override the constant DefaultACMEDirectory so that autocert will use the staging environment, or even if this is possible.

I am using golang http module as my web server.

The operating system my web server runs on is (include version):Centos 7

My hosting provider, if applicable, is: DigitalOcean

I can login to a root shell on my machine

Regards in advance of any help/suggestions.

1 Like

Hi @Dabnis

change that value.

Constants ¶

const DefaultACMEDirectory = "https://acme-v02.api.letsencrypt.org/directory"
1 Like

Thanks Juergen. I had considered that, but have always viewed changing working third party code as a bad practice! However in this instance it seems to be the only option available to me given that the value is a constant.

Thank you, your help is very much appreciated.

Changing the constant is indeed not the right thing to do. When you instantiate the autocert.Manager, pass in your own *acme.Client:

package main

import (

func main() {
	manager := &autocert.Manager{
		Client: &acme.Client{
			DirectoryURL: "https://some.acme.server/dir",
1 Like

Thank you _az. Although changing the autocert constant did work ‘I think: as I still have HTTPS/docker issues’’, your solution looks right so I will mark it as the solution.

Thank You

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.