Gets the Certificate RabbitMQ API client.

        Returns:
            CertificateRabbitMQ:
1471
def certificate_rabbitmq(self):
        
        if not self.__certificate_rabbitmq:
            self.__certificate_rabbitmq = CertificateRabbitMQ(self.__connection)
        return self.__certificate_rabbitmq
913060
def get_credentials(cls, consumer_key, code):
        '''
        

        '''
        headers = {
            'X-Accept': 'application/json',
        }
        url = 'https://getpocket.com/v3/oauth/authorize'
        payload = {
            'consumer_key': consumer_key,
            'code': code,
        }

        return cls._make_request(url, payload, headers)[0]
1253751
def certificate_object(self):
        
        if not self.certificate:
            return None
        self.certificate.seek(0)
        return crypto.parse_certificate(self.certificate.read())
1353112
def _get_rabbitmq_plugin():
    '''
    
    '''
    global RABBITMQ_PLUGINS

    if RABBITMQ_PLUGINS is None:
        version = __salt__['pkg.version']('rabbitmq-server').split('-')[0]
        RABBITMQ_PLUGINS = ('/usr/lib/rabbitmq/lib/rabbitmq_server-{0}'
                            '/sbin/rabbitmq-plugins').format(version)

    return RABBITMQ_PLUGINS
20879
def get_ssl_connection(config):
    
    cd = pymqi.CD()
    cd.ChannelName = config.channel
    cd.ConnectionName = config.host_and_port
    cd.ChannelType = pymqi.CMQC.MQCHT_CLNTCONN
    cd.TransportType = pymqi.CMQC.MQXPT_TCP
    cd.SSLCipherSpec = config.ssl_cipher_spec

    sco = pymqi.SCO()
    sco.KeyRepository = config.ssl_key_repository_location

    queue_manager = pymqi.QueueManager(None)
    queue_manager.connect_with_options(config.queue_manager_name, cd, sco)

    return queue_manager
564633
def _get_client(self, server):
        
        return Client(
            server=server[0],
            authport=server[1],
            secret=server[2],
            dict=self._get_dictionary(),
        )
782568
def establish_rabbitmq_connection(rabbitmq_uri):
    
    userid, password, host, port, virtual_host, ssl = translate_rabbitmq_url(rabbitmq_uri)

    connection = Connection(userid=userid,
                            password=password,
                            host=host,
                            port=port,
                            virtual_host=virtual_host,
                            ssl=False)

    return connection
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)
1285555
def retrieve_client_credentials(self):
        
        client_id = self.params.get('client_id')
        client_secret = self.params.get('client_secret')
        return (client_id, client_secret)
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
331346
def _get_client(self):
        
        client_kwargs = self._storage_parameters.get('client', dict())

        # Handles unsecure mode
        if self._unsecure:
            client_kwargs = client_kwargs.copy()
            client_kwargs['use_ssl'] = False

        return self._get_session().client("s3", **client_kwargs)
127134
def obtain_socket(uri)
      socket = TCPSocket.new(uri.host, uri.port || socket_port(uri))

      if secure_uri?(uri)
        ctx = OpenSSL::SSL::SSLContext.new

        if ENV['DISCORDRB_SSL_VERIFY_NONE']
          ctx.ssl_version = 'SSLv23'
          ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # use VERIFY_PEER for verification

          cert_store = OpenSSL::X509::Store.new
          cert_store.set_default_paths
          ctx.cert_store = cert_store
        else
          ctx.set_params ssl_version: :TLSv1_2
        end

        socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)
        socket.connect
      end

      socket
    end
210717
def certificate_authority(self):
        
        if not self.__certificate_authority:
            self.__certificate_authority = CertificateAuthority(self.__connection)
        return self.__certificate_authority
431962
def get_request(self):
        
        # Accept the client
        client_socket, client_address = self.socket.accept()

        if ssl is not None and self.cert_file:
            # Setup an SSL context to accept clients with a certificate
            # signed by a known chain of authority.
            # Other clients will be rejected during handshake.
            context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
            try:
                # Force a valid/signed client-side certificate
                context.verify_mode = ssl.CERT_REQUIRED

                # Load the server certificate
                context.load_cert_chain(
                    certfile=self.cert_file,
                    keyfile=self.key_file,
                    password=self.key_password,
                )

                if self.ca_file:
                    # Load the given authority chain
                    context.load_verify_locations(self.ca_file)
                else:
                    # Load the default chain if none given
                    context.load_default_certs(ssl.Purpose.CLIENT_AUTH)
            except Exception as ex:
                # Explicitly log the error as the default behaviour hides it
                _logger.error("Error setting up the SSL context: %s", ex)
                raise

            try:
                # SSL handshake
                client_stream = context.wrap_socket(
                    client_socket, server_side=True
                )
            except ssl.SSLError as ex:
                # Explicitly log the exception before re-raising it
                _logger.warning(
                    "Error during SSL handshake with %s: %s", client_address, ex
                )
                raise
        else:
            # Nothing to do, use the raw socket
            client_stream = client_socket

        return client_stream, client_address
903468
private String getCerticateSubject(AtomicServiceReference<Object> serviceRef, Properties sslProperties) {
        String certificateDN = null;
        try {
            certificateDN = sslHelper.getClientKeyCertSubject(serviceRef, sslProperties);
        } catch (KeyStoreException ke) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.error(tc, "CWKKD0020.ssl.get.certificate.user", MONGO, id, ke);
            }
            throw new RuntimeException(Tr.formatMessage(tc, "CWKKD0020.ssl.get.certificate.user", MONGO, id, ke));
        } catch (CertificateException ce) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.error(tc, "CWKKD0020.ssl.get.certificate.user", MONGO, id, ce);
            }
            throw new RuntimeException(Tr.formatMessage(tc, "CWKKD0020.ssl.get.certificate.user", MONGO, id, ce));
        }

        // handle null .... cannot find the client key
        if (certificateDN == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.error(tc, "CWKKD0026.ssl.certificate.exception", MONGO, id);
            }
            throw new RuntimeException(Tr.formatMessage(tc, "CWKKD0026.ssl.certificate.exception", MONGO, id));
        }

        return certificateDN;
    }
308731
def get_kafka_ssl_context():
    
    # NOTE: We assume that Kafka environment variables are present. If using
    # Apache Kafka on Heroku, they will be available in your app configuration.
    #
    # 1. Write the PEM certificates necessary for connecting to the Kafka brokers to physical
    # files.  The broker connection SSL certs are passed in environment/config variables and
    # the python and ssl libraries require them in physical files.  The public keys are written
    # to short lived NamedTemporaryFile files; the client key is encrypted before writing to
    # the short lived NamedTemporaryFile
    #
    # 2. Create and return an SSLContext for connecting to the Kafka brokers referencing the
    # PEM certificates written above
    #

    # stash the kafka certs in named temporary files for loading into SSLContext.  Initialize the
    # SSLContext inside the with so when it goes out of scope the files are removed which has them
    # existing for the shortest amount of time.  As extra caution password
    # protect/encrypt the client key
    with NamedTemporaryFile(suffix='.crt') as cert_file, \
         NamedTemporaryFile(suffix='.key') as key_file, \
         NamedTemporaryFile(suffix='.crt') as trust_file:
        cert_file.write(os.environ['KAFKA_CLIENT_CERT'].encode('utf-8'))
        cert_file.flush()

        # setup cryptography to password encrypt/protect the client key so it's not in the clear on
        # the filesystem.  Use the generated password in the call to load_cert_chain
        passwd = standard_b64encode(os.urandom(33))
        private_key = serialization.load_pem_private_key(
            os.environ['KAFKA_CLIENT_CERT_KEY'].encode('utf-8'),
            password=None,
            backend=default_backend()
        )
        pem = private_key.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.BestAvailableEncryption(passwd)
        )
        key_file.write(pem)
        key_file.flush()

        trust_file.write(os.environ['KAFKA_TRUSTED_CERT'].encode('utf-8'))
        trust_file.flush()

        # create an SSLContext for passing into the kafka provider using the create_default_context
        # function which creates an SSLContext with protocol set to PROTOCOL_SSLv23, OP_NO_SSLv2,
        # and OP_NO_SSLv3 when purpose=SERVER_AUTH.
        ssl_context = ssl.create_default_context(
            purpose=ssl.Purpose.SERVER_AUTH, cafile=trust_file.name)
        ssl_context.load_cert_chain(cert_file.name, keyfile=key_file.name, password=passwd)

        # Intentionally disabling hostname checking.  The Kafka cluster runs in the cloud and Apache
        # Kafka on Heroku doesn't currently provide stable hostnames.  We're pinned to a specific certificate
        # for this connection even though the certificate doesn't include host information.  We rely
        # on the ca trust_cert for this purpose.
        ssl_context.check_hostname = False

    return ssl_context
751136
def cert_pair(self):
        
        if self._ssl_cert and self._ssl_private_key:
            return (self._ssl_cert, self._ssl_private_key)
        else:
            return None