Python ACME package usage

from acme import client

from josepy import jwk




net = client.ClientNetwork(key={
    "y": "...",
    "x": "7ynkZT5-...",
    "crv": "P-256",
    "kty": "EC",
    "d": "..."
})




c = client.ClientV2('https://acme-staging-v02.api.letsencrypt.org/directory', net)



ret = c.new_order("""-----BEGIN CERTIFICATE REQUEST-----
MIICvzCCAacCAQAwejELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCUJKIFN0cmVldDEQ
MA4GA1UEBwwHQmVpamluZzESMBAGA1UECgwJUWluZ0Nsb3VkMRcwFQYDVQQLDA5E
ZXYgRGVwYXJ0bWVudDEYMBYGA1UEAwwPbGV0c2VuY3J5cHQudG9wMIIBIjANBgkq
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt6snycLptLaARz3Dwq6jtToUd3jIa6wu
E...................gEBAD6G17rOy5qDM4W5hy1PDLmKEg/OQDrF9X0MclrN
tDw1ecvI4qd/ZYdvWna4bQx0B+KLjsIEffQdr8K+fff6ARxf9SBpt3gzpYWsrNe3
+TWAXkAfv4zu3lcGWWu4VmG/6/kn/Rf6rlweACnKRhpSB7ZmeDfHTlPJ6kdu5ets
7KtVEkCD7fZjADVxMYeOMAuClF2bmsL7GCH6nz2ELqPKS8N3BNJW+HDQe3rBgeQs
vnV8daG1KQ7N4XZ7+2ug3AAqcMKADBeAZq3Tneq7ZQCQNAxkXgqTaFauqNaYTUJg
ugbgMmvNNvCeKCOTB50szgd1JYtk47W6knf9awRyMh1pKLg=
-----END CERTIFICATE REQUEST-----
""")

get exception:


........ /lib/python2.7/site-packages/acme/client.py", line 668, in new_order
    response = self._post(self.directory['newOrder'], order)
TypeError: string indices must be integers, not str

How to use this package ?

I installed it by pip install acme

The acme.client.ClientV2 constructor expects directory to be a a acme.messages.Directory object:

what does USER_AGENT mean?

Try look it up in that file I linked. Also:

ACME clients MUST send a User-Agent header field, in accordance with [RFC7231]. This header field SHOULD include the name and version of the ACME software in addition to the name and version of the underlying HTTP client software.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.