Skip to content

request_domain can set fullchain_der, privkey_der on ssl_options #141

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

Closed
wants to merge 1 commit into from

Conversation

kapouer
Copy link

@kapouer kapouer commented Jun 7, 2018

Hi,

i needed this in order to provide a wildcard certificate:

  • does not fill autossl cache with a copy for each domain
  • uses autossl ocsp logic to avoid nginx taking over

It requires some extra work in init_by_lua, see this example.

@kapouer
Copy link
Author

kapouer commented Jun 7, 2018

It's a simple man's #97 solution.

@abozhinov
Copy link

Hi,
do you have some success with wilcard certs?

@kapouer
Copy link
Author

kapouer commented Dec 17, 2018

Well yes, provided you have a third-party tool (like certbot on debian) to update the certificates.

@kapouer
Copy link
Author

kapouer commented Jun 3, 2025

This is actually not needed, as someone can write directly to auto_ssl shared dict,
using that kind of logic:

auto_ssl:set("request_domain", function(ssl)
    local domain, err = ssl.server_name()
    if not err and domain ~= nil then
      local ssldict = ngx.shared.auto_ssl
      local fullKey = "domain:fullchain_der:" .. domain
      if ssldict:get(fullKey) == nil then
        local privKey = "domain:privkey_der:" .. domain
        for rootDomain, rootPem in pairs(rootPems) do
          local rootLen = rootDomain:len()
          if domain:sub(-rootLen) == rootDomain and domain:find(".", 1, true) >= domain:len() - rootLen then
            ssldict:set(fullKey, rootPem.full)
            ssldict:set(privKey, rootPem.key)
          end
        end
      end
    end
    return domain, err
  end)

@kapouer kapouer closed this Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants