#!/usr/bin/python3
-import sys, os, getopt, binascii, json, pprint, signal, time
+import sys, os, getopt, binascii, json, pprint, signal, time, threading
import urllib.request
import Crypto.PublicKey.RSA, Crypto.Random, Crypto.Hash.SHA256, Crypto.Signature.PKCS1_v1_5
+class msgerror(Exception):
+ def report(self, out):
+ out.write("acmecert: undefined error\n")
+
service = "https://acme-v02.api.letsencrypt.org/directory"
_directory = None
def directory():
self.fp.close()
return False
-class usageerr(Exception):
- pass
-
+invdata = threading.local()
commands = {}
+class usageerr(msgerror):
+ def __init__(self):
+ self.cmd = invdata.cmd
+
+ def report(self, out):
+ out.write("%s\n" % (self.cmd.__doc__,))
+
def cmd_reg(args):
"usage: acmecert reg [OUTPUT-FILE]"
acct = register()
usage(sys.stderr)
sys.exit(1)
try:
- cmd(args)
- except usageerr:
- sys.stderr.write("%s\n" % (cmd.__doc__,))
+ try:
+ invdata.cmd = cmd
+ cmd(args)
+ finally:
+ invdata.cmd = None
+ except msgerror as exc:
+ exc.report(sys.stderr)
sys.exit(1)
if __name__ == "__main__":