[Erp5-report] r42502 luke - /erp5/trunk/products/Vifib/Tool/CertificateAuthorityTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 20 09:38:18 CET 2011


Author: luke
Date: Thu Jan 20 09:38:18 2011
New Revision: 42502

URL: http://svn.erp5.org?rev=42502&view=rev
Log:
 - allow basic formatting of error
 - adapt logic a bit, require common name to generate certificate

Modified:
    erp5/trunk/products/Vifib/Tool/CertificateAuthorityTool.py

Modified: erp5/trunk/products/Vifib/Tool/CertificateAuthorityTool.py
URL: http://svn.erp5.org/erp5/trunk/products/Vifib/Tool/CertificateAuthorityTool.py?rev=42502&r1=42501&r2=42502&view=diff
==============================================================================
--- erp5/trunk/products/Vifib/Tool/CertificateAuthorityTool.py [utf8] (original)
+++ erp5/trunk/products/Vifib/Tool/CertificateAuthorityTool.py [utf8] Thu Jan 20 09:38:18 2011
@@ -44,7 +44,7 @@ def popenCommunicate(command_list, input
   if popen.returncode is None:
     popen.kill()
   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))
   return result
 
@@ -178,8 +178,8 @@ class CertificateAuthorityTool(BaseTool)
                           )
 
   security.declareProtected(Permissions.AccessContentsInformation, 'getNewCertificate')
-  def getNewCertificate(self):
-    """Returns dictionary {key, certificate, id} where id is certificate id to be used"""
+  def getNewCertificate(self, common_name):
+    """Returns certificate for passed common name, as dictionary of {key, certificate, serial, common_name}"""
     self._checkCertificateAuthority()
     self._lockCertificateAuthority()
     try:
@@ -190,7 +190,7 @@ class CertificateAuthorityTool(BaseTool)
       try:
         popenCommunicate([self.openssl_binary, 'req', '-nodes', '-config',
           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',
           '-batch', '-config', self.openssl_config, '-out', cert, '-infiles',
           csr])
@@ -198,7 +198,8 @@ class CertificateAuthorityTool(BaseTool)
         return dict(
           key=open(key).read(),
           certificate=open(cert).read(),
-          id=new_id)
+          id=new_id,
+          common_name=common_name)
       except:
         try:
           for p in [key, csr, cert]:



More information about the Erp5-report mailing list