pylego 0.1.31__py3-none-any.whl → 0.1.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pylego/lego.go +22 -10
- pylego/lego.so +0 -0
- pylego/pylego.py +23 -11
- {pylego-0.1.31.dist-info → pylego-0.1.32.dist-info}/METADATA +1 -1
- pylego-0.1.32.dist-info/RECORD +11 -0
- pylego-0.1.31.dist-info/RECORD +0 -11
- {pylego-0.1.31.dist-info → pylego-0.1.32.dist-info}/WHEEL +0 -0
- {pylego-0.1.31.dist-info → pylego-0.1.32.dist-info}/licenses/LICENSE +0 -0
- {pylego-0.1.31.dist-info → pylego-0.1.32.dist-info}/top_level.txt +0 -0
pylego/lego.go
CHANGED
|
@@ -12,6 +12,7 @@ import (
|
|
|
12
12
|
"errors"
|
|
13
13
|
"fmt"
|
|
14
14
|
"os"
|
|
15
|
+
"time"
|
|
15
16
|
|
|
16
17
|
"github.com/go-acme/lego/v4/certcrypto"
|
|
17
18
|
"github.com/go-acme/lego/v4/certificate"
|
|
@@ -24,12 +25,13 @@ import (
|
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
type LegoInputArgs struct {
|
|
27
|
-
Email
|
|
28
|
-
PrivateKey
|
|
29
|
-
Server
|
|
30
|
-
CSR
|
|
31
|
-
Plugin
|
|
32
|
-
Env
|
|
28
|
+
Email string `json:"email"`
|
|
29
|
+
PrivateKey string `json:"private_key,omitempty"`
|
|
30
|
+
Server string `json:"server"`
|
|
31
|
+
CSR string `json:"csr"`
|
|
32
|
+
Plugin string `json:"plugin"`
|
|
33
|
+
Env map[string]string
|
|
34
|
+
DNSPropagationWait int `json:"dns_propagation_wait,omitempty"`
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
type LegoOutputResponse struct {
|
|
@@ -58,7 +60,7 @@ func RunLegoCommand(message *C.char) *C.char {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
}
|
|
61
|
-
certificate, err := requestCertificate(CLIArgs.Email, CLIArgs.PrivateKey, CLIArgs.Server, CLIArgs.CSR, CLIArgs.Plugin)
|
|
63
|
+
certificate, err := requestCertificate(CLIArgs.Email, CLIArgs.PrivateKey, CLIArgs.Server, CLIArgs.CSR, CLIArgs.Plugin, CLIArgs.DNSPropagationWait)
|
|
62
64
|
if err != nil {
|
|
63
65
|
return C.CString(fmt.Sprint("error: couldn't request certificate: ", err))
|
|
64
66
|
}
|
|
@@ -70,7 +72,7 @@ func RunLegoCommand(message *C.char) *C.char {
|
|
|
70
72
|
return return_message_ptr
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
func requestCertificate(email, privateKeyPem, server, csr, plugin string) (*LegoOutputResponse, error) {
|
|
75
|
+
func requestCertificate(email, privateKeyPem, server, csr, plugin string, propagationWait int) (*LegoOutputResponse, error) {
|
|
74
76
|
var privateKey crypto.PrivateKey
|
|
75
77
|
if privateKeyPem != "" {
|
|
76
78
|
parsedKey, err := certcrypto.ParsePEMPrivateKey([]byte(privateKeyPem))
|
|
@@ -99,7 +101,7 @@ func requestCertificate(email, privateKeyPem, server, csr, plugin string) (*Lego
|
|
|
99
101
|
return nil, fmt.Errorf("couldn't create lego client: %s", err)
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
err = configureClientChallenges(client, plugin)
|
|
104
|
+
err = configureClientChallenges(client, plugin, propagationWait)
|
|
103
105
|
if err != nil {
|
|
104
106
|
return nil, fmt.Errorf("couldn't configure client challenges: %s", err)
|
|
105
107
|
}
|
|
@@ -140,7 +142,7 @@ func requestCertificate(email, privateKeyPem, server, csr, plugin string) (*Lego
|
|
|
140
142
|
}, nil
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
func configureClientChallenges(client *lego.Client, plugin string) error {
|
|
145
|
+
func configureClientChallenges(client *lego.Client, plugin string, propagationWait int) error {
|
|
144
146
|
switch plugin {
|
|
145
147
|
case "", "http":
|
|
146
148
|
if err := client.Challenge.SetHTTP01Provider(http01.NewProviderServer(os.Getenv("HTTP01_IFACE"), os.Getenv("HTTP01_PORT"))); err != nil {
|
|
@@ -157,9 +159,19 @@ func configureClientChallenges(client *lego.Client, plugin string) error {
|
|
|
157
159
|
if err != nil {
|
|
158
160
|
return errors.Join(fmt.Errorf("couldn't create %s provider: ", plugin), err)
|
|
159
161
|
}
|
|
162
|
+
var wait time.Duration
|
|
163
|
+
if propagationWait < 0 {
|
|
164
|
+
return fmt.Errorf("DNS_PROPAGATION_WAIT cannot be negative: %d", propagationWait)
|
|
165
|
+
}
|
|
166
|
+
if propagationWait > 0 {
|
|
167
|
+
wait = time.Duration(propagationWait) * time.Second
|
|
168
|
+
}
|
|
169
|
+
|
|
160
170
|
err = client.Challenge.SetDNS01Provider(dnsProvider,
|
|
161
171
|
dns01.CondOption(os.Getenv("DNS_PROPAGATION_DISABLE_ANS") != "",
|
|
162
172
|
dns01.DisableAuthoritativeNssPropagationRequirement()),
|
|
173
|
+
dns01.CondOption(wait > 0,
|
|
174
|
+
dns01.PropagationWait(wait, true)),
|
|
163
175
|
dns01.CondOption(os.Getenv("DNS_PROPAGATION_RNS") != "", dns01.RecursiveNSsPropagationRequirement()))
|
|
164
176
|
if err != nil {
|
|
165
177
|
return errors.Join(fmt.Errorf("couldn't set %s DNS provider server: ", plugin), err)
|
pylego/lego.so
CHANGED
|
Binary file
|
pylego/pylego.py
CHANGED
|
@@ -35,7 +35,13 @@ class LEGOError(Exception):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def run_lego_command(
|
|
38
|
-
email: str,
|
|
38
|
+
email: str,
|
|
39
|
+
server: str,
|
|
40
|
+
csr: bytes,
|
|
41
|
+
env: dict[str, str],
|
|
42
|
+
plugin: str = "",
|
|
43
|
+
private_key: str = "",
|
|
44
|
+
dns_propagation_wait: int | None = None,
|
|
39
45
|
) -> LEGOResponse:
|
|
40
46
|
"""Run an arbitrary command in the Lego application. Read more at https://go-acme.github.io.
|
|
41
47
|
|
|
@@ -47,21 +53,27 @@ def run_lego_command(
|
|
|
47
53
|
env: the environment variables required for the chosen plugin.
|
|
48
54
|
private_key: the private key to be used for the registration on the ACME server (not the private key used to sign the CSR).
|
|
49
55
|
If not provided, a new one will be generated.
|
|
56
|
+
dns_propagation_wait: optional wait duration for DNS propagation, in seconds (int).
|
|
50
57
|
"""
|
|
51
58
|
library.RunLegoCommand.restype = ctypes.c_char_p
|
|
52
59
|
library.RunLegoCommand.argtypes = [ctypes.c_char_p]
|
|
53
60
|
|
|
61
|
+
if dns_propagation_wait is not None and dns_propagation_wait < 0:
|
|
62
|
+
raise ValueError("dns_propagation_wait cannot be negative")
|
|
63
|
+
|
|
64
|
+
payload = {
|
|
65
|
+
"email": email,
|
|
66
|
+
"server": server,
|
|
67
|
+
"csr": csr.decode(),
|
|
68
|
+
"plugin": plugin,
|
|
69
|
+
"env": env,
|
|
70
|
+
"private_key": private_key,
|
|
71
|
+
}
|
|
72
|
+
if dns_propagation_wait is not None:
|
|
73
|
+
payload["dns_propagation_wait"] = dns_propagation_wait
|
|
74
|
+
|
|
54
75
|
message = bytes(
|
|
55
|
-
json.dumps(
|
|
56
|
-
{
|
|
57
|
-
"email": email,
|
|
58
|
-
"server": server,
|
|
59
|
-
"csr": csr.decode(),
|
|
60
|
-
"plugin": plugin,
|
|
61
|
-
"env": env,
|
|
62
|
-
"private_key": private_key,
|
|
63
|
-
}
|
|
64
|
-
),
|
|
76
|
+
json.dumps(payload),
|
|
65
77
|
"utf-8",
|
|
66
78
|
)
|
|
67
79
|
result: bytes = library.RunLegoCommand(message)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pylego
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.32
|
|
4
4
|
Summary: A python wrapper package for the lego application written in Golang
|
|
5
5
|
Author-email: Canonical <telco-engineers@lists.canonical.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/canonical/pylego
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
pylego/__init__.py,sha256=7rcUcQcOWsOLxTOEXF2ASkwm_7eED1UIXzxdlgKPr5c,82
|
|
2
|
+
pylego/go.mod,sha256=2zddNtfcY9OT_qrCABQwRB06dvL0QF9kMA1E6lmvOlM,12467
|
|
3
|
+
pylego/go.sum,sha256=-Gl6lIAbKb0cjJHr4dVvA4_XGBSHONqL0lKRGHUoYn0,187420
|
|
4
|
+
pylego/lego.go,sha256=Fw9klKd_4pQV6SKn7O2WXLs-M_ta_l5nxZhluov0EeU,6509
|
|
5
|
+
pylego/lego.so,sha256=iY76dyNQa-lhximqoLrdTJPJ7ATqfbo_z1xncZEbprM,87362384
|
|
6
|
+
pylego/pylego.py,sha256=HgNEnKndDHskz5SoB3tOdSDNyd73E9X57Y3Ksvfog1Q,2609
|
|
7
|
+
pylego-0.1.32.dist-info/licenses/LICENSE,sha256=aklz9Y8CIpFsN61U4jHlJYp4W_8HoDpY-tINlDcdSZY,10934
|
|
8
|
+
pylego-0.1.32.dist-info/METADATA,sha256=hX8nkvZacF4-eZZk5Y_2TGxKWZ_ZJgNywHy6c3rtmXM,5776
|
|
9
|
+
pylego-0.1.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
pylego-0.1.32.dist-info/top_level.txt,sha256=pSOYv55_w90qy3xOvqz_ysSz-X-XRTb-jMpiOyLNnNs,7
|
|
11
|
+
pylego-0.1.32.dist-info/RECORD,,
|
pylego-0.1.31.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
pylego/__init__.py,sha256=7rcUcQcOWsOLxTOEXF2ASkwm_7eED1UIXzxdlgKPr5c,82
|
|
2
|
-
pylego/go.mod,sha256=2zddNtfcY9OT_qrCABQwRB06dvL0QF9kMA1E6lmvOlM,12467
|
|
3
|
-
pylego/go.sum,sha256=-Gl6lIAbKb0cjJHr4dVvA4_XGBSHONqL0lKRGHUoYn0,187420
|
|
4
|
-
pylego/lego.go,sha256=O_tXZN6DRXlVXJfZdjIXTrDWXyn1UuBeZa_ZzPCnGOA,6004
|
|
5
|
-
pylego/lego.so,sha256=97DWk_jF6PWw5qR3S4wPRZ6K8vP_4_LE03eYhJLO7wA,61313170
|
|
6
|
-
pylego/pylego.py,sha256=x9NTkBi1P4ITPhGBUgMCHVBHqFN7NXAJAc9aknKLcgk,2263
|
|
7
|
-
pylego-0.1.31.dist-info/licenses/LICENSE,sha256=aklz9Y8CIpFsN61U4jHlJYp4W_8HoDpY-tINlDcdSZY,10934
|
|
8
|
-
pylego-0.1.31.dist-info/METADATA,sha256=gsUgrPUL3EI5U0px3y0lbf3magHQayI5TC41NrDR9Qc,5776
|
|
9
|
-
pylego-0.1.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
pylego-0.1.31.dist-info/top_level.txt,sha256=pSOYv55_w90qy3xOvqz_ysSz-X-XRTb-jMpiOyLNnNs,7
|
|
11
|
-
pylego-0.1.31.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|