Commit 08018506 authored by Łukasz Nowak's avatar Łukasz Nowak

- allow basic formatting of error

 - adapt logic a bit, require common name to generate certificate


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42502 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9014e120
...@@ -44,7 +44,7 @@ def popenCommunicate(command_list, input=None, **kwargs): ...@@ -44,7 +44,7 @@ def popenCommunicate(command_list, input=None, **kwargs):
if popen.returncode is None: if popen.returncode is None:
popen.kill() popen.kill()
if popen.returncode != 0: if popen.returncode != 0:
raise ValueError('Issue during calling %r, result was: %r' % (command_list, raise ValueError('Issue during calling %r, result was:\n%s' % (command_list,
result)) result))
return result return result
...@@ -178,8 +178,8 @@ class CertificateAuthorityTool(BaseTool): ...@@ -178,8 +178,8 @@ class CertificateAuthorityTool(BaseTool):
) )
security.declareProtected(Permissions.AccessContentsInformation, 'getNewCertificate') security.declareProtected(Permissions.AccessContentsInformation, 'getNewCertificate')
def getNewCertificate(self): def getNewCertificate(self, common_name):
"""Returns dictionary {key, certificate, id} where id is certificate id to be used""" """Returns certificate for passed common name, as dictionary of {key, certificate, serial, common_name}"""
self._checkCertificateAuthority() self._checkCertificateAuthority()
self._lockCertificateAuthority() self._lockCertificateAuthority()
try: try:
...@@ -190,7 +190,7 @@ class CertificateAuthorityTool(BaseTool): ...@@ -190,7 +190,7 @@ class CertificateAuthorityTool(BaseTool):
try: try:
popenCommunicate([self.openssl_binary, 'req', '-nodes', '-config', popenCommunicate([self.openssl_binary, 'req', '-nodes', '-config',
self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days', self.openssl_config, '-new', '-keyout', key, '-out', csr, '-days',
'3650'], '%s\n' % new_id, stdin=subprocess.PIPE) '3650'], '%s\n' % common_name, stdin=subprocess.PIPE)
popenCommunicate([self.openssl_binary, 'ca', '-days', '3650', popenCommunicate([self.openssl_binary, 'ca', '-days', '3650',
'-batch', '-config', self.openssl_config, '-out', cert, '-infiles', '-batch', '-config', self.openssl_config, '-out', cert, '-infiles',
csr]) csr])
...@@ -198,7 +198,8 @@ class CertificateAuthorityTool(BaseTool): ...@@ -198,7 +198,8 @@ class CertificateAuthorityTool(BaseTool):
return dict( return dict(
key=open(key).read(), key=open(key).read(),
certificate=open(cert).read(), certificate=open(cert).read(),
id=new_id) id=new_id,
common_name=common_name)
except: except:
try: try:
for p in [key, csr, cert]: for p in [key, csr, cert]:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment