def _GetPuppetSslDetails(self, cert_fname=None, interactive_user=False):
    """Get Puppet SSL details.

    Args:
      cert_fname: str, optional, certification filename.
      interactive_user: bool, optional, default False,
        True if the client user an interactive user who can be prompted
        for auth.
    Returns:
      dict = {
          'cert': str, X509 format client certificate in PEM format,
          'ca_cert': str, X509 format CA certificate in PEM format,
          'priv_key': str, X509 format private key in PEM format,
          'cn': str, commonName of this client's certificate
      }
      or {} if the details cannot be read.
    """
    # TODO(user): unit test the puppet ssl cert harvesting functions.
    logging.debug('_GetPuppetSslDetails(%s)', cert_fname)
    certs_path = os.path.join(self.CLIENT_SSL_PATH, self.PUPPET_CERTS)

    best_cert = None
    priv_key = False
    output = {}
    cert_name = None

    if not cert_fname:  # if cert filename is not passed, check facter.
      try:
        facts = self.GetFacter()
      except FacterError:
        # don't give up, facter fails from time to time.
        facts = {}
      cert_name = facts.get('certname', None)
      if cert_name:
        cert_name = cert_name.strip()
        logging.debug('Certname from facter: "%s"', cert_name)
        cert_name = cert_name.lower()
        cert_fname = '%s.pem' % cert_name
      else:
        logging.debug('Error obtaining certname from facter')
        cert_fname = None

    if cert_fname:
      try:
        # attempt to get the cert passed as cert_fname,
        # or returned from facter.
        self._ValidatePuppetSslCert(certs_path, cert_fname)
        best_cert = cert_fname
      except PuppetSslCertError:
        # could not harvest the cert facter tells us to use, look for others.
        logging.error('Failed to harvest Puppet SSL cert facter specified.')

    if not best_cert:
      best_cert = self._GetNewestPuppetSslCert()

    # found, using the same filename look for the private cert.
    if best_cert:
      cn = best_cert.rsplit('.', 1)[0]
      priv_key = os.path.join(
          self.CLIENT_SSL_PATH, self.PUPPET_PRIVATE_KEYS, best_cert)
      logging.debug('_GetPuppetSslDetails priv should be %s', priv_key)

      # is it there?
      if self._IsFile(priv_key, requires_root=True, sudo_ok=interactive_user):
        output['cn'] = cn
        output['cert'] = self._LoadFile(os.path.join(
            self.CLIENT_SSL_PATH, self.PUPPET_CERTS, best_cert))
        output['priv_key'] = self._LoadFile(
            priv_key, requires_root=True, sudo_ok=interactive_user)
      else:
        logging.debug('_GetPuppetSslDetails not IsFile %s', priv_key)

    # NOTE(user):  There is a maximum size of a single syslog message
    # under OS X on Python (the exact value of which seems to depend on OS
    # X version)
    if 'headers' in output:
      logging.info('Output headers = %s', output['headers'])
    return output
dataset/ETHPy150Open google/simian/src/simian/client/client.py/HttpsAuthClient._GetPuppetSslDetails/original