45 import pkg.misc as misc |
49 import pkg.misc as misc |
46 import pkg.publish.transaction as trans |
50 import pkg.publish.transaction as trans |
47 from pkg.client import global_settings |
51 from pkg.client import global_settings |
48 from pkg.client.debugvalues import DebugValues |
52 from pkg.client.debugvalues import DebugValues |
49 from pkg.misc import emsg, msg, PipeError |
53 from pkg.misc import emsg, msg, PipeError |
50 import M2Crypto as m2 |
|
51 |
54 |
52 PKG_CLIENT_NAME = "pkgsign" |
55 PKG_CLIENT_NAME = "pkgsign" |
53 |
56 |
54 # pkg exit codes |
57 # pkg exit codes |
55 EXIT_OK = 0 |
58 EXIT_OK = 0 |
105 |
108 |
106 return src_pub.catalog |
109 return src_pub.catalog |
107 |
110 |
108 def __make_tmp_cert(d, pth): |
111 def __make_tmp_cert(d, pth): |
109 try: |
112 try: |
110 cert = m2.X509.load_cert(pth) |
113 with open(pth, "rb") as f: |
111 except m2.X509.X509Error as e: |
114 cert = x509.load_pem_x509_certificate(f.read(), |
|
115 default_backend()) |
|
116 except (ValueError, IOError) as e: |
112 raise api_errors.BadFileFormat(_("The file {0} was expected to " |
117 raise api_errors.BadFileFormat(_("The file {0} was expected to " |
113 "be a PEM certificate but it could not be read.").format( |
118 "be a PEM certificate but it could not be read.").format( |
114 pth)) |
119 pth)) |
115 fd, fp = tempfile.mkstemp(dir=d) |
120 fd, fp = tempfile.mkstemp(dir=d) |
116 with os.fdopen(fd, "wb") as fh: |
121 with os.fdopen(fd, "wb") as fh: |
117 fh.write(cert.as_pem()) |
122 fh.write(cert.public_bytes(serialization.Encoding.PEM)) |
118 return fp |
123 return fp |
119 |
124 |
120 def main_func(): |
125 def main_func(): |
121 misc.setlocale(locale.LC_ALL, "", error) |
126 misc.setlocale(locale.LC_ALL, "", error) |
122 gettext.install("pkg", "/usr/share/locale", |
127 gettext.install("pkg", "/usr/share/locale", |