Get the certificates file for https
353914
def get_cert_file():
    
    try:
        current_path = os.path.realpath(__file__)
        ca_cert_path = os.path.join(current_path, "..", "..", "..",
                                    "conf", "cacert.pem")
        return os.path.abspath(ca_cert_path)
    except Exception:
        return None
541108
def get_ssl_context(private_key, certificate):
    
    if (
        certificate
        and os.path.isfile(certificate)
        and private_key
        and os.path.isfile(private_key)
    ):
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
        context.load_cert_chain(certificate, private_key)
        return context
    return None
443757
def create_ssl_certificate(cert_params)
      file_path = cert_params[:output_file].sub(/\.(\w+)$/, "")
      path = prompt_for_file_path
      file_path = File.join(path, file_path) unless path.empty?
      cert_params[:domain] = prompt_for_domain

      rsa_key = generate_keypair cert_params[:key_length]
      cert = generate_certificate(rsa_key, cert_params)
      write_certificate_to_file cert, file_path, rsa_key, cert_params
      puts "*" * 70
      puts "Generated Certificates:"
      puts "- #{file_path}.pfx - PKCS12 format keypair. Contains both the public and private keys, usually used on the server."
      puts "- #{file_path}.b64 - Base64 encoded PKCS12 keypair. Contains both the public and private keys, for upload to the Azure REST API."
      puts "- #{file_path}.pem - Base64 encoded public certificate only. Required by the client to connect to the server."
      puts "Certificate Thumbprint: #{@thumbprint.to_s.upcase}"
      puts "*" * 70

      Chef::Config[:knife][:ca_trust_file] = file_path + ".pem" if Chef::Config[:knife][:ca_trust_file].nil?
      cert_data = File.read (file_path + ".b64")
      add_certificate cert_data, @winrm_cert_passphrase, "pfx", cert_params[:azure_dns_name]
      @thumbprint
    end
371800
function(path, secure) {
      var root = app.get('static url').replace(/.*:\/\//, '');
      var proto = 'http';

      if (path && path[0] === '/') {
        path = path.slice(1);
      }

      if (secure) {
        root =
          undefsafe(config, 'url.ssl.static') ||
          undefsafe(config, 'url.static') ||
          undefsafe(config, 'url.host');
        proto = 'https';
      }

      return path
        ? proto + '://' + root + '/' + (path || '')
        : proto + '://' + root;
    }
914943
function getServerConfig(aCertDir) {
    const certFileRead = readFile(aCertDir + '/serverCert.pem');
    const keyFileRead = readFile(aCertDir + '/serverKey.pem');
    return Promise.all([certFileRead, keyFileRead]).
      then(files => [{ cert: files[0], key: files[1] }]);
  }
1328692
def _get_url(ssl, url, port, path):
    '''
    
    '''
    if ssl:
        return 'https://{0}:{1}/management/domain/{2}'.format(url, port, path)
    else:
        return 'http://{0}:{1}/management/domain/{2}'.format(url, port, path)
352423
function readCertificateDataFromFile ({ keyFile, certFile, caFile }) {
  let key, cert, ca;

  if (keyFile) {
    key = fs.readFileSync(keyFile);
  }

  if (certFile) {
    cert = fs.readFileSync(certFile);
  }

  if (caFile) {
    ca = fs.readFileSync(caFile);
  }

  return { key, cert, ca };
}
103045
def get_certificates_der_v3(self):
        

        if self._v3_signing_data == None:
            self.parse_v3_signing_block()

        certs = []
        for signed_data in [signer.signed_data for signer in self._v3_signing_data]:
            for cert in signed_data.certificates:
                certs.append(cert)

        return certs
867537
def _get_ssl_opts():
    '''
    
    '''
    sslopts = __salt__['config.option']('cassandra').get('ssl_options', None)
    ssl_opts = {}

    if sslopts:
        ssl_opts['ca_certs'] = sslopts['ca_certs']
        if SSL_VERSION in sslopts:
            if not sslopts[SSL_VERSION].startswith('PROTOCOL_'):
                valid_opts = ', '.join(
                    [x for x in dir(ssl) if x.startswith('PROTOCOL_')]
                )
                raise CommandExecutionError('Invalid protocol_version '
                                            'specified! '
                                            'Please make sure '
                                            'that the ssl protocol'
                                            'version is one from the SSL'
                                            'module. '
                                            'Valid options are '
                                            '{0}'.format(valid_opts))
            else:
                ssl_opts[SSL_VERSION] = \
                    getattr(ssl, sslopts[SSL_VERSION])
        return ssl_opts
    else:
        return None
239474
def verifyChainFromCAFile(self, cafile, untrusted_file=None):
        
        try:
            f = open(cafile, "rb")
            ca_certs = f.read()
            f.close()
        except Exception:
            raise Exception("Could not read from cafile")

        anchors = [Cert(c) for c in split_pem(ca_certs)]

        untrusted = None
        if untrusted_file:
            try:
                f = open(untrusted_file, "rb")
                untrusted_certs = f.read()
                f.close()
            except Exception:
                raise Exception("Could not read from untrusted_file")
            untrusted = [Cert(c) for c in split_pem(untrusted_certs)]

        return self.verifyChain(anchors, untrusted)
759373
def load(self):
        """"""

        private = self.is_private()
        with open_tls_file(self.file_path, 'r', private=private) as fh:
            if private:
                self.x509 = crypto.load_privatekey(self.encoding, fh.read())
            else:
                self.x509 = crypto.load_certificate(self.encoding, fh.read())
            return self.x509
1275961
def get_certificate
      uri = URI.parse(URI.escape(@host))
      options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE }
      Net::HTTP.start(uri.host, uri.port, options) do |http|
        http.peer_cert
      end
    end
324467
def show_cert(id_):
    '''
    
    '''
    data = __utils__['http.query'](
        '{0}/certificaterequests/{1}/certificate'.format(_base_url(), id_),
        params={
            'format': 'PEM',
            'chainOrder': 'ROOT_FIRST'
        },
        status=True,
        text=True,
        header_dict={'tppl-api-key': _api_key()},
    )
    status = data['status']
    if six.text_type(status).startswith('4') or six.text_type(status).startswith('5'):
        raise CommandExecutionError(
            'There was an API error: {0}'.format(data['error'])
        )
    data = data.get('body', '')
    csr_data = __utils__['http.query'](
        '{0}/certificaterequests/{1}'.format(_base_url(), id_),
        status=True,
        decode=True,
        decode_type='json',
        header_dict={'tppl-api-key': _api_key()},
    )
    status = csr_data['status']
    if six.text_type(status).startswith('4') or six.text_type(status).startswith('5'):
        raise CommandExecutionError(
            'There was an API error: {0}'.format(csr_data['error'])
        )
    csr_data = csr_data.get('dict', {})
    certs = _parse_certs(data)
    dns_name = ''
    for item in csr_data['certificateName'].split(','):
        if item.startswith('cn='):
            dns_name = item.split('=')[1]
    #certs['CSR Data'] = csr_data

    cache = salt.cache.Cache(__opts__, syspaths.CACHE_DIR)
    domain_data = cache.fetch('venafi/domains', dns_name)
    if domain_data is None:
        domain_data = {}
    certs['private_key'] = domain_data.get('private_key')
    domain_data.update(certs)
    cache.store('venafi/domains', dns_name, domain_data)

    certs['request_id'] = id_
    return certs
241132
def get_file(self, secure_data_path, version=None):
        

        query = self._get_file(secure_data_path, version)
        resp = query.headers.copy()
        resp = self._parse_metadata_filename(resp)
        resp['data'] = query.content

        return resp
1265172
def find_ca_bundle():
    """"""
    extant_cert_paths = filter(os.path.isfile, cert_paths)
    return (
        get_win_certfile()
        or next(extant_cert_paths, None)
        or _certifi_where()
    )
64594
private void parseSSLCertFile() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "parseSSLCertFile");
        }

        String fileName = null;
        String lineRead = null;
        BufferedReader bufferReader = null;

        // Obtain Default Cert Label
        certDefaultLabel = getProperty(PROTOCOL_HTTPS_CERT_DEFAULT_LABEL);

        // Obtain Cert Mapping File
        try {
            fileName = getProperty(PROTOCOL_HTTPS_CERT_MAPPING_FILE);

            if (fileName != null && 0 < fileName.length()) {
                bufferReader = new BufferedReader(new FileReader(fileName));

                // For each entry, parse the label and ip address
                lineRead = bufferReader.readLine();
                while (lineRead != null) {
                    extractSSLServerCert(lineRead.trim());
                    lineRead = bufferReader.readLine();
                }
            }
        } catch (Exception e) {
            FFDCFilter.processException(e, getClass().getName(), "parseSSLCertFile", this);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Error parsing file; " + e);
        } finally {
            if (null != bufferReader) {
                try {
                    bufferReader.close();
                } catch (IOException ioe) {
                    // ignore
                }
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "parseSSLCertFile");
        }
    }
202096
def get(self, bits=2048, type=crypto.TYPE_RSA, digest='sha1'):
        
        self.log.debug('Creating a new self-signed SSL certificate')
        # Generate the key and ready our cert
        key = crypto.PKey()
        key.generate_key(type, bits)
        cert = crypto.X509()

        # Fill in some pseudo certificate information with a wildcard common name
        cert.get_subject().C  = 'US'
        cert.get_subject().ST = 'California'
        cert.get_subject().L  = 'Los Angeles'
        cert.get_subject().O  = 'Wright Anything Agency'
        cert.get_subject().OU = 'Law firm / talent agency'
        cert.get_subject().CN = '*.{dn}'.format(dn=self.site.domain.name)

        # Set the serial number, expiration and issued
        cert.set_serial_number(1000)
        cert.gmtime_adj_notBefore(0)
        cert.gmtime_adj_notAfter(315360000)
        cert.set_issuer(cert.get_subject())

        # Map the key and sign our certificate
        cert.set_pubkey(key)
        cert.sign(key, digest)

        # Dump the PEM data and return a certificate container
        _cert = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)
        _key  = crypto.dump_privatekey(crypto.FILETYPE_PEM, key)

        return Certificate(_cert, _key, type, bits, digest)