(subject, rsa_bits=2048, passphrase=None)
return (csr, private_key, passphrase)
Generate a Certificate Signing Request.

  Args:
    subject: str, subject for csr
    rsa_bits: int, optional number of bits
    passphrase: str, optional passphrase to encrypt private key with

  Returns:
    tuple, cert and private key in PEM format and passphrase

  Raises:
    CertError: Error generating a CSR.
Generate a Certificate Signing Request.
Generate a Certificate Signing Request .
def GenerateCSR(subject, rsa_bits=2048, passphrase=None):
  """Generate a Certificate Signing Request.

  Args:
    subject: str, subject for csr
    rsa_bits: int, optional number of bits
    passphrase: str, optional passphrase to encrypt private key with

  Returns:
    tuple, cert and private key in PEM format and passphrase

  Raises:
    CertError: Error generating a CSR.
  """
  command = [CMD_OPENSSL, 'genrsa']
  env = {}
  if passphrase:
    command.extend(['-des3', '-passout', 'env:PASSPHRASE'])
    env['PASSPHRASE'] = passphrase
  command.extend([str(rsa_bits)])

  logging.debug('command: %s', command)
  logging.debug('environment: %s', env.keys())
  (stdout, stderr, status) = gmacpyutil.RunProcess(command, env=env)
  logging.debug('Private key generation output: %s', stdout)
  if status:
    raise CertError('Error creating private key: %s' % stderr)
  private_key = stdout

  command = [CMD_OPENSSL, 'req', '-new', '-subj', subject, '-key',
             '/dev/stdin']
  if passphrase:
    command.extend(['-passin', 'env:PASSPHRASE'])
    env['PASSPHRASE'] = passphrase

  logging.debug('command: %s', command)
  logging.debug('environment: %s', env.keys())
  logging.debug('stdinput: %s', private_key)
  (csr, stderr, status) = gmacpyutil.RunProcess(command, private_key, env=env)
  logging.debug('CSR generation output: %s', csr)
  if status:
    raise CertError('Error creating CSR: %s' % stderr)

  return (csr, private_key, passphrase)
def GenerateCSR ( subject , rsa_bits = 2048 , passphrase = None ) : command = [ CMD_OPENSSL , 'genrsa' ] env = { } if passphrase : command . extend ( [ '-des3' , '-passout' , 'env:PASSPHRASE' ] ) env [ 'PASSPHRASE' ] = passphrase command . extend ( [ str ( rsa_bits ) ] ) logging . debug ( 'command: %s' , command ) logging . debug ( 'environment: %s' , env . keys ( ) ) ( stdout , stderr , status ) = gmacpyutil . RunProcess ( command , env = env ) logging . debug ( 'Private key generation output: %s' , stdout ) if status : raise CertError ( 'Error creating private key: %s' % stderr ) private_key = stdout command = [ CMD_OPENSSL , 'req' , '-new' , '-subj' , subject , '-key' , '/dev/stdin' ] if passphrase : command . extend ( [ '-passin' , 'env:PASSPHRASE' ] ) env [ 'PASSPHRASE' ] = passphrase logging . debug ( 'command: %s' , command ) logging . debug ( 'environment: %s' , env . keys ( ) ) logging . debug ( 'stdinput: %s' , private_key ) ( csr , stderr , status ) = gmacpyutil . RunProcess ( command , private_key , env = env ) logging . debug ( 'CSR generation output: %s' , csr ) if status : raise CertError ( 'Error creating CSR: %s' % stderr ) return ( csr , private_key , passphrase )