Skip to content
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

Support for preferred_chains in Caddyfile #4185

Closed
Klooven opened this issue Jun 2, 2021 · 5 comments · Fixed by #4192
Closed

Support for preferred_chains in Caddyfile #4185

Klooven opened this issue Jun 2, 2021 · 5 comments · Fixed by #4192
Labels
feature ⚙️ New feature or request good first issue 🐤 Good for newcomers help wanted 🆘 Extra attention is needed

Comments

@Klooven
Copy link
Contributor

Klooven commented Jun 2, 2021

As mentioned in #3854, Let's Encrypt now provides two different chains when acquiring a certificate: one with a cross-signed root certificate (default) and one with a self-signed root certificate.

I'd like to use the alternative chain, which seems to be possible using the preferred_chains option in Caddy. From what I've understood, though, this is currently only configurable through JSON.

Would it be possible to add a new global option in the Caddyfile to support changing the preferred chain without configuring Caddy using JSON?

@mholt mholt added feature ⚙️ New feature or request good first issue 🐤 Good for newcomers help wanted 🆘 Extra attention is needed labels Jun 2, 2021
@mholt
Copy link
Member

mholt commented Jun 2, 2021

Sure, pull requests welcomed to add that.

@Klooven
Copy link
Contributor Author

Klooven commented Jun 4, 2021

Cool! I've been playing around with the Caddy source code and with my very limited experience of Go, I managed to get it work somehow... Only as a global option for now, though. I'll send in a PR for review in the near future.

A couple of questions @mholt:


type ChainPreference struct {
// Prefer chains with the fewest number of bytes.
Smallest *bool `json:"smallest,omitempty"`
// Select first chain having a root with one of
// these common names.
RootCommonName []string `json:"root_common_name,omitempty"`
// Select first chain that has any issuer with one
// of these common names.
AnyCommonName []string `json:"any_common_name,omitempty"`
}

Should PreferredChains only accept one of the above options at the time?

  • For example if I set Smallest to true, should RootCommonName and AnyCommonName be accepted?
  • Or if I, for example, set RootCommonName to some value, should any of the other two remaining options be accepted?

I've used the following structure for the (global) config:

{
  preferred_chains [smallest] {
    root_common_name <common names...>
    any_common_name  <common names...>
  }
}

And for a "local" config the structure would be the same except that it is of course placed in the ACME issuer config:

localhost

...

tls {
  issuer acme {
    preferred_chains...
  }
}

The config could be done in the following ways, for example:

{
  preferred_chains smallest
}
{
  preferred_chains {
    root_common_name "Example root name" "Example root name 2"
  }
}

Does that structure seem good, or should I adjust it in some way?

@mholt
Copy link
Member

mholt commented Jun 4, 2021

@Klooven Nice work -- I think that structure looks good, at least good enough for a PR.

Congrats figuring out Go!

@Klooven
Copy link
Contributor Author

Klooven commented Jun 5, 2021

Created PR #4192!

If everything is ok and it gets merged, I'd be happy to update the docs on the website as well.

@francislavoie
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request good first issue 🐤 Good for newcomers help wanted 🆘 Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants