get the cert and the restapiid
169117
function reads(callback) {
      parallel({
        cert(callback) {
          acm.listCertificates({}, callback)
        },
        apis(callback) {
          gw.getRestApis({
            limit: 500,
          }, callback)
        }
      }, callback)
    }
105159
function() {
      var cert;
      try {
        cert = this.keychain.getCertPem();
      } catch (e) {
        throw new CError({
          body: {
            code: 'ImATeapot',
            message: 'missing certificate',
            cause: e
          }
        }).log('body');
      }
      if (!cert) {
        throw new CError('missing certificate').log();
      }
      if (!this.getDate()) {
        throw new CError('missing date').log();
      }
      if (!this.getSid()) {
        throw new CError('missing session identifier').log();
      }
      if (!this.getId()) {
        throw new CError('missing id').log();
      }
      if (!this.getApp()) {
        throw new CError('missing app').log();
      }
      var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::';
      if (this._reply) {
        // NOTE: username is not mandatory in non browser environment
        // NOTE: SECRET_SERVER is present only when the client is used inside the authorify module
        var username = this.getUsername();
        if (!username) {
          username = 'anonymous';
        }
        var password = this.getPassword();
        if (!password) {
          password = forge.util.encode64(forge.random.getBytesSync(16));
        }
        tmp += username + '::' + password + '::' + SECRET_SERVER;
      } else {
        tmp += SECRET_CLIENT;
      }
      var hmac = forge.hmac.create();
      hmac.start('sha256', SECRET);
      hmac.update(tmp);
      return hmac.digest().toHex();
    }
565998
def query_certificate(self, cert_hash):
        
        try:
            cquery = self.pssl.query_cert(cert_hash)
        except Exception:
            self.error('Exception during processing with passiveSSL. '
                       'This happens if the given hash is not sha1 or contains dashes/colons etc. '
                       'Please make sure to submit a clean formatted sha1 hash.')

        # fetch_cert raises an error if no certificate was found.
        try:
            cfetch = self.pssl.fetch_cert(cert_hash, make_datetime=False)
        except Exception:
            cfetch = {}

        return {'query': cquery,
                'cert': cfetch}
128816
def api_version(self, verbose=False):
        '''
        
        '''
        return self.__auth_req_get(self.rest_url, verbose=verbose)
739573
def GetPublicCert(self):
    

    cert_url = self.google_api_url + 'publicKeys'

    resp, content = self.http.request(cert_url)
    if resp.status == 200:
      return simplejson.loads(content)
    else:
      raise errors.GitkitServerError('Error response for cert url: %s' %
                                     content)
755109
def _get_options(ret=None):
    '''
    
    '''
    defaults = {'host': 'salt',
                'user': 'salt',
                'pass': 'salt',
                'db': 'salt',
                'port': 3306,
                'ssl_ca': None,
                'ssl_cert': None,
                'ssl_key': None}

    attrs = {'host': 'host',
             'user': 'user',
             'pass': 'pass',
             'db': 'db',
             'port': 'port',
             'ssl_ca': 'ssl_ca',
             'ssl_cert': 'ssl_cert',
             'ssl_key': 'ssl_key'}

    _options = salt.returners.get_returner_options(__virtualname__,
                                                   ret,
                                                   attrs,
                                                   __salt__=__salt__,
                                                   __opts__=__opts__,
                                                   defaults=defaults)
    # post processing
    for k, v in six.iteritems(_options):
        if isinstance(v, six.string_types) and v.lower() == 'none':
            # Ensure 'None' is rendered as None
            _options[k] = None
        if k == 'port':
            # Ensure port is an int
            _options[k] = int(v)

    return _options
1330567
def _retrieveRemoteCertificate(self, From, port=port):
        
        CS = self.service.certificateStorage
        host = str(From.domainAddress())
        p = AMP()
        p.wrapper = self.wrapper
        f = protocol.ClientCreator(reactor, lambda: p)
        connD = f.connectTCP(host, port)

        def connected(proto):
            dhost = From.domainAddress()
            iddom = proto.callRemote(Identify, subject=dhost)
            def gotCert(identifyBox):
                theirCert = identifyBox['certificate']
                theirIssuer = theirCert.getIssuer().commonName
                theirName = theirCert.getSubject().commonName
                if (theirName != str(dhost)):
                    raise VerifyError(
                        "%r claimed it was %r in IDENTIFY response"
                        % (theirName, dhost))
                if (theirIssuer != str(dhost)):
                    raise VerifyError(
                        "self-signed %r claimed it was issued by "
                        "%r in IDENTIFY response" % (dhost, theirIssuer))
                def storedCert(ignored):
                    return theirCert
                return CS.storeSelfSignedCertificate(
                    str(dhost), theirCert).addCallback(storedCert)
            def nothingify(x):
                proto.transport.loseConnection()
                return x
            return iddom.addCallback(gotCert).addBoth(nothingify)
        connD.addCallback(connected)
        return connD
977445
def decode_cert(cert):
    

    ret_dict = {}
    subject_xname = X509_get_subject_name(cert.value)
    ret_dict["subject"] = _create_tuple_for_X509_NAME(subject_xname)

    notAfter = X509_get_notAfter(cert.value)
    ret_dict["notAfter"] = ASN1_TIME_print(notAfter)

    peer_alt_names = _get_peer_alt_names(cert)
    if peer_alt_names is not None:
        ret_dict["subjectAltName"] = peer_alt_names

    return ret_dict
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
881275
def decode_der(cert_der):
    
    return cryptography.x509.load_der_x509_certificate(
        data=cert_der, backend=cryptography.hazmat.backends.default_backend()
    )
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
1177877
def get(self, param=None, must=[APIKEY]):
        '''
        '''
        param = {} if param is None else param
        r = self.verify_param(param, must)
        if not r.is_succ():
            return r
        handle = CommonResultHandler(lambda rsp: {VERSION_V1:rsp.get(USER), VERSION_V2:rsp}[self.version()])
        return self.path('get.json').post(param, handle, r)
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
519172
function() {
      if (this.getMode() !== mode) {
        throw new CError('unexpected mode').log();
      }
      var cert;
      try {
        cert = this.keychain.getCertPem();
      } catch (e) {
        throw new CError({
          body: {
            code: 'ImATeapot',
            message: 'missing certificate',
            cause: e
          }
        }).log('body');
      }
      if (!cert) {
        throw new CError('missing certificate').log();
      }
      var out = {
        mode: this.getMode(),
        cert: cert
      };
      if (this.getSid()) {
        out.sid = this.getSid();
      }
      return out;
    }
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
119445
def pem_to_der(cert, return_multiple=True):
    

    # initialize the certificate array
    cert_list = []

    # If certificate is in DER then un-armour it
    if pem.detect(cert):
        for _, _, der_bytes in pem.unarmor(cert, multiple=True):
            cert_list.append(der_bytes)
    else:
        cert_list.append(cert)

    # return multiple if return_multiple is set else first element
    if return_multiple:
        return cert_list
    else:
        return cert_list.pop()
162528
def _get_tls_object(self, ssl_params):
        
        if ssl_params is None:
            return None

        if not ssl_params["verify"] and ssl_params["ca_certs"]:
            self.warning(
                "Incorrect configuration: trying to disable server certificate validation, "
                "while also specifying a capath. No validation will be performed. Fix your "
                "configuration to remove this warning"
            )

        validate = ssl.CERT_REQUIRED if ssl_params["verify"] else ssl.CERT_NONE

        if ssl_params["ca_certs"] is None or os.path.isfile(ssl_params["ca_certs"]):
            tls = ldap3.core.tls.Tls(
                local_private_key_file=ssl_params["key"],
                local_certificate_file=ssl_params["cert"],
                ca_certs_file=ssl_params["ca_certs"],
                version=ssl.PROTOCOL_SSLv23,
                validate=validate,
            )
        elif os.path.isdir(ssl_params["ca_certs"]):
            tls = ldap3.core.tls.Tls(
                local_private_key_file=ssl_params["key"],
                local_certificate_file=ssl_params["cert"],
                ca_certs_path=ssl_params["ca_certs"],
                version=ssl.PROTOCOL_SSLv23,
                validate=validate,
            )
        else:
            raise ConfigurationError(
                'Invalid path {} for ssl_ca_certs: no such file or directory'.format(ssl_params['ca_certs'])
            )
        return tls