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

[How to] use certbot plugin gandi not in CLI #29

Open
Benouare opened this issue Aug 16, 2021 · 1 comment
Open

[How to] use certbot plugin gandi not in CLI #29

Benouare opened this issue Aug 16, 2021 · 1 comment

Comments

@Benouare
Copy link

Benouare commented Aug 16, 2021

Hi,

Current behavior :

I am generating certs well with certbot/gandi-plugin on NASs, but to do that i am forced to share my DNS_GANDI_KEY with NASs.

The finality :

I would like to integrate the certificate generation process in a python app (django on Gandi instance). With this, my clients will not know my DNS_GANDI_KEY anymore. My app will be the only one that knows this api key. I will provide the certificates to each NAS.

What i want :

I am looking for some python code that is using certbot and plugin-gandi (or needs some adaptations to use it), and make me able to generate my certs using only python (no shell, and i dont want to use subprocess that is calling python app/lib... ).

What i did :

I tried to dig into the code of certbot/gandi-plugin, but I didnt find a good entry point yet.

Any help?

Merci pour la lib', super boulot!

Ressources :

PS : just found this, that's more or less what i am looking for (in my case i will use DNS-Challenge)
https://gist.github.com/gpjt/2bd2a223b410d8fcfb782d0df1be2e00

@Benouare
Copy link
Author

Benouare commented Aug 16, 2021

Ok.
Found something with certbot.main

edit

import certbot.main
from django.conf import settings


def __prepare_params_generate(domain):
    params = "certonly -n -a dns-gandi --dns-gandi-credentials {} --domain {} --email {} --agree-tos --config-dir {} --work-dir {} --logs-dir {}".format(
        settings.GANDI_FILE_CONF_CERT,
        domain,
        settings.GANDI_EMAIL_CERT,
        settings.GANDI_CONFIG_DIR_CERT,
        settings.GANDI_WORK_DIR_CERT,
        settings.GANDI_LOG_DIR_CERT,
    )
    return params.split(" ")


def generate_cert(domain):
    certbot.main.main(__prepare_params_generate(domain))

This works.

@Benouare Benouare changed the title How to use certbot plugin gandi not in CLI [How to] use certbot plugin gandi not in CLI [Solved] Aug 16, 2021
@Benouare Benouare changed the title [How to] use certbot plugin gandi not in CLI [Solved] [How to] use certbot plugin gandi not in CLI Aug 16, 2021
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

No branches or pull requests

1 participant