pylego 0.1.9__py3-none-any.whl → 0.1.25__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/go.mod +115 -90
- pylego/go.sum +736 -241
- pylego/lego.go +21 -10
- pylego/lego.so +0 -0
- pylego/pylego.py +4 -1
- {pylego-0.1.9.dist-info → pylego-0.1.25.dist-info}/METADATA +7 -9
- pylego-0.1.25.dist-info/RECORD +11 -0
- {pylego-0.1.9.dist-info → pylego-0.1.25.dist-info}/WHEEL +1 -1
- pylego-0.1.9.dist-info/RECORD +0 -11
- {pylego-0.1.9.dist-info → pylego-0.1.25.dist-info/licenses}/LICENSE +0 -0
- {pylego-0.1.9.dist-info → pylego-0.1.25.dist-info}/top_level.txt +0 -0
pylego/lego.go
CHANGED
|
@@ -23,11 +23,12 @@ import (
|
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
type LegoInputArgs struct {
|
|
26
|
-
Email
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
Email string `json:"email"`
|
|
27
|
+
PrivateKey string `json:"private_key,omitempty"`
|
|
28
|
+
Server string `json:"server"`
|
|
29
|
+
CSR string `json:"csr"`
|
|
30
|
+
Plugin string `json:"plugin"`
|
|
31
|
+
Env map[string]string
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
type LegoOutputResponse struct {
|
|
@@ -56,7 +57,7 @@ func RunLegoCommand(message *C.char) *C.char {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
}
|
|
59
|
-
certificate, err := requestCertificate(CLIArgs.Email, CLIArgs.Server, CLIArgs.CSR, CLIArgs.Plugin)
|
|
60
|
+
certificate, err := requestCertificate(CLIArgs.Email, CLIArgs.PrivateKey, CLIArgs.Server, CLIArgs.CSR, CLIArgs.Plugin)
|
|
60
61
|
if err != nil {
|
|
61
62
|
return C.CString(fmt.Sprint("error: couldn't request certificate: ", err))
|
|
62
63
|
}
|
|
@@ -68,10 +69,20 @@ func RunLegoCommand(message *C.char) *C.char {
|
|
|
68
69
|
return return_message_ptr
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
func requestCertificate(email, server, csr, plugin string) (*LegoOutputResponse, error) {
|
|
72
|
-
privateKey
|
|
73
|
-
if
|
|
74
|
-
|
|
72
|
+
func requestCertificate(email, privateKeyPem, server, csr, plugin string) (*LegoOutputResponse, error) {
|
|
73
|
+
var privateKey crypto.PrivateKey
|
|
74
|
+
if privateKeyPem != "" {
|
|
75
|
+
parsedKey, err := certcrypto.ParsePEMPrivateKey([]byte(privateKeyPem))
|
|
76
|
+
if err != nil {
|
|
77
|
+
return nil, fmt.Errorf("couldn't parse private key: %s", err)
|
|
78
|
+
}
|
|
79
|
+
privateKey = parsedKey
|
|
80
|
+
} else {
|
|
81
|
+
generatedKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
|
82
|
+
if err != nil {
|
|
83
|
+
return nil, fmt.Errorf("couldn't generate priv key: %s", err)
|
|
84
|
+
}
|
|
85
|
+
privateKey = generatedKey
|
|
75
86
|
}
|
|
76
87
|
user := LetsEncryptUser{
|
|
77
88
|
Email: email,
|
pylego/lego.so
CHANGED
|
Binary file
|
pylego/pylego.py
CHANGED
|
@@ -35,7 +35,7 @@ class LEGOError(Exception):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def run_lego_command(
|
|
38
|
-
email: str, server: str, csr: bytes, env: dict[str, str], plugin: str = ""
|
|
38
|
+
email: str, server: str, csr: bytes, env: dict[str, str], plugin: str = "", private_key: str = ""
|
|
39
39
|
) -> LEGOResponse:
|
|
40
40
|
"""Run an arbitrary command in the Lego application. Read more at https://go-acme.github.io.
|
|
41
41
|
|
|
@@ -45,6 +45,8 @@ def run_lego_command(
|
|
|
45
45
|
csr: the csr to be signed
|
|
46
46
|
plugin: which DNS provider plugin to use for the request. Find yours at https://go-acme.github.io/lego/dns/.
|
|
47
47
|
env: the environment variables required for the chosen plugin.
|
|
48
|
+
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
|
+
If not provided, a new one will be generated.
|
|
48
50
|
"""
|
|
49
51
|
library.RunLegoCommand.restype = ctypes.c_char_p
|
|
50
52
|
library.RunLegoCommand.argtypes = [ctypes.c_char_p]
|
|
@@ -57,6 +59,7 @@ def run_lego_command(
|
|
|
57
59
|
"csr": csr.decode(),
|
|
58
60
|
"plugin": plugin,
|
|
59
61
|
"env": env,
|
|
62
|
+
"private_key": private_key,
|
|
60
63
|
}
|
|
61
64
|
),
|
|
62
65
|
"utf-8",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pylego
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.25
|
|
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
|
|
@@ -8,13 +8,10 @@ Project-URL: Issues, https://github.com/canonical/pylego/issues
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
|
|
15
|
-
Requires-Dist: pytest; extra == "test"
|
|
16
|
-
Requires-Dist: requests; extra == "test"
|
|
17
|
-
Requires-Dist: ruff; extra == "test"
|
|
14
|
+
Dynamic: license-file
|
|
18
15
|
|
|
19
16
|
# pylego
|
|
20
17
|
|
|
@@ -37,16 +34,17 @@ You can import the lego command and run any function that you can run from the C
|
|
|
37
34
|
```python
|
|
38
35
|
from pylego import run_lego_command
|
|
39
36
|
test_env = {"NAMECHEAP_API_USER": "user", "NAMECHEAP_API_KEY": "key"}
|
|
40
|
-
run_lego_command("something@gmail.com", "https://localhost/directory", "-----BEGIN CERTIFICATE REQUEST----- ...", "namecheap", test_env)
|
|
37
|
+
run_lego_command("something@gmail.com", "https://localhost/directory", "-----BEGIN CERTIFICATE REQUEST----- ...", "namecheap", test_env, "-----BEGIN RSA PRIVATE KEY-----")
|
|
41
38
|
```
|
|
42
39
|
|
|
43
40
|
| Argument | Description |
|
|
44
41
|
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
45
|
-
| `email` | The provided email will be registered to
|
|
42
|
+
| `email` | The provided email will be registered to the ACME server. It may receive some emails notifying the user about certificate expiry. |
|
|
46
43
|
| `server` | This is the full URL of a server that implements the ACME protocol. While letsencrypt is the most common one, there are other programs that provide this facility like Vault. |
|
|
47
44
|
| `csr` | This must be a PEM string in bytes that is user generated and valid as according to the ACME server that is being provided above. Many providers have different requirements for what is allowed to be in the fields of the CSR. |
|
|
48
45
|
| `plugin` | The plugin is a string that's supported by LEGO. The full list is located [here](https://go-acme.github.io/lego/dns/). On top of the LEGO provided ones, we have an extra plugin called `http` that will allow users to use HTTP01 and TLSALPN01 challenges. |
|
|
49
46
|
| `env` | The env is a dictionary mapping of strings to strings that will be loaded into the environment for LEGO to use. All plugins require some configuration values loaded into the environment. You can find them [here](https://go-acme.github.io/lego/dns/) |
|
|
47
|
+
| `private_key` | The provided private key will be used to register the user to the ACME server (not the key that signed the CSR), if not provided pylego will generate a new one |
|
|
50
48
|
|
|
51
49
|
On top of the environment variables that LEGO supports, we have some extra ones that we use to configure the library:
|
|
52
50
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
pylego/__init__.py,sha256=7rcUcQcOWsOLxTOEXF2ASkwm_7eED1UIXzxdlgKPr5c,82
|
|
2
|
+
pylego/go.mod,sha256=n2-zLjKRREhmUyfj0u-VQRyEvmlp4wJcVY_Ret6v2bw,10759
|
|
3
|
+
pylego/go.sum,sha256=vWXQ9GPwP6WPKjCuQ1_sWDka9PjTL2Yh28nIQeWKU80,146531
|
|
4
|
+
pylego/lego.go,sha256=iXzvfVQ19PxqwFkgfxT8ueRdtIT6-cegjuzOzSuHkWs,5678
|
|
5
|
+
pylego/lego.so,sha256=ObOt7e40UbDoYqJSEmuxdVvux0yQRT2VUWREKrtGRjs,161224160
|
|
6
|
+
pylego/pylego.py,sha256=LD5BF1c0FM0p3M4Mqz62edNwsM0vV-tJ9J16VCWbyJU,2233
|
|
7
|
+
pylego-0.1.25.dist-info/licenses/LICENSE,sha256=aklz9Y8CIpFsN61U4jHlJYp4W_8HoDpY-tINlDcdSZY,10934
|
|
8
|
+
pylego-0.1.25.dist-info/METADATA,sha256=HXxrOi6AMeyJemyvn8DE1nlNNclk5oo7juLllTwnB30,5637
|
|
9
|
+
pylego-0.1.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
pylego-0.1.25.dist-info/top_level.txt,sha256=pSOYv55_w90qy3xOvqz_ysSz-X-XRTb-jMpiOyLNnNs,7
|
|
11
|
+
pylego-0.1.25.dist-info/RECORD,,
|
pylego-0.1.9.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
pylego/__init__.py,sha256=7rcUcQcOWsOLxTOEXF2ASkwm_7eED1UIXzxdlgKPr5c,82
|
|
2
|
-
pylego/go.mod,sha256=S-5MY_3fsoWvQMLkUAox6lnwtL3IX05pjiAlPQhfwPU,9469
|
|
3
|
-
pylego/go.sum,sha256=HpR7HGB2ICojeKlw4xYXn_Q2dwUv1oS8GuYPTBXrk9I,98044
|
|
4
|
-
pylego/lego.go,sha256=52e3iR6uc70EszJDNYCpM_78Cb6zZuYj1kK9L5ZBz9Y,5281
|
|
5
|
-
pylego/lego.so,sha256=oeSx3nCQaTCUsUCagXOtjbBoINksfgv8XrLp6mDHGZE,140895672
|
|
6
|
-
pylego/pylego.py,sha256=bHsVzqMM2DZmhCAn-yqlxKQ4Pr5QRyOpBjP2dJSBKMU,1976
|
|
7
|
-
pylego-0.1.9.dist-info/LICENSE,sha256=aklz9Y8CIpFsN61U4jHlJYp4W_8HoDpY-tINlDcdSZY,10934
|
|
8
|
-
pylego-0.1.9.dist-info/METADATA,sha256=2soVxPs33-JahfztbWOY_i9RG4_LYej0vuOq4zgTjpY,5528
|
|
9
|
-
pylego-0.1.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
10
|
-
pylego-0.1.9.dist-info/top_level.txt,sha256=pSOYv55_w90qy3xOvqz_ysSz-X-XRTb-jMpiOyLNnNs,7
|
|
11
|
-
pylego-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|