当前位置: 首页>>代码示例>>Python>>正文


Python SSLDomain.set_peer_authentication方法代码示例

本文整理汇总了Python中proton.SSLDomain.set_peer_authentication方法的典型用法代码示例。如果您正苦于以下问题:Python SSLDomain.set_peer_authentication方法的具体用法?Python SSLDomain.set_peer_authentication怎么用?Python SSLDomain.set_peer_authentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在proton.SSLDomain的用法示例。


在下文中一共展示了SSLDomain.set_peer_authentication方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: opts_ssl_domain

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
def opts_ssl_domain(opts, mode=SSLDomain.MODE_CLIENT):
    """Return proton.SSLDomain from command line options or None if no SSL options specified.
    @param opts: Parsed optoins including connection_options()
    """

    certificate, key, trustfile, password, password_file, ssl_disable_peer_name_verify = opts.ssl_certificate,\
                                                                                         opts.ssl_key,\
                                                                                         opts.ssl_trustfile,\
                                                                                         opts.ssl_password,\
                                                                                         opts.ssl_password_file, \
                                                                                         opts.ssl_disable_peer_name_verify

    if not (certificate or trustfile):
        return None

    if password_file:
        password = get_password(password_file)

    domain = SSLDomain(mode)

    if trustfile:
        domain.set_trusted_ca_db(str(trustfile))
        if ssl_disable_peer_name_verify:
            domain.set_peer_authentication(SSLDomain.VERIFY_PEER, str(trustfile))
        else:
            domain.set_peer_authentication(SSLDomain.VERIFY_PEER_NAME, str(trustfile))

    if certificate:
        domain.set_credentials(str(certificate), str(key), str(password))
    return domain
开发者ID:lulf,项目名称:qpid-dispatch,代码行数:32,代码来源:command.py

示例2: run

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
    def run(self):
        try:
            ssl = SSLDomain(SSLDomain.MODE_CLIENT)
            ssl.set_credentials(str(self.options.accountPublicKey), str(self.options.accountPrivateKey), str(""))
            ssl.set_trusted_ca_db(str(self.options.brokerPublicKey))
            ssl.set_peer_authentication(SSLDomain.VERIFY_PEER_NAME, trusted_CAs=str(self.options.brokerPublicKey))

            connection = BlockingConnection(self.address, ssl_domain=ssl, heartbeat=60000)
            receiver = connection.create_receiver(self.broadcast_address, credit=self.capacity)

            while True:
                received_message = None

                try:
                    received_message = receiver.receive(timeout=self.options.timeout)
                except Timeout, e:
                    print("-I- No message received for ", self.options.timeout, " seconds")
                    break

                self.message_counter += 1
                print("-I- Received broadcast message: " + received_message.body)
                receiver.accept()

            print("-I- " + str(self.message_counter) + " messages received")

            connection.close()
开发者ID:Eurex-Clearing-Messaging-Interfaces,项目名称:Python-Code-Examples,代码行数:28,代码来源:BlockingBroadcastReceiver.py

示例3: on_start

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
    def on_start(self, event):
        self.container = event.container

        ssl = SSLDomain(SSLDomain.MODE_CLIENT)
        ssl.set_credentials(str(self.options.accountPublicKey), str(self.options.accountPrivateKey), str(""))
        ssl.set_trusted_ca_db(str(self.options.brokerPublicKey))
        ssl.set_peer_authentication(SSLDomain.VERIFY_PEER_NAME, trusted_CAs=str(self.options.brokerPublicKey))

        conn = event.container.connect(self.address, ssl_domain=ssl, heartbeat=60000, allowed_mechs=str("EXTERNAL"))
        event.container.create_receiver(conn, self.broadcast_address)
开发者ID:Eurex-Clearing-Messaging-Interfaces,项目名称:Python-Code-Examples,代码行数:12,代码来源:BroadcastReceiver.py

示例4: opts_ssl_domain

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
def opts_ssl_domain(opts, mode=SSLDomain.MODE_CLIENT):
    """Return proton.SSLDomain from command line options or None if no SSL options specified.
    @param opts: Parsed optoins including connection_options()
    """
    certificate, key, trustfile, password = opts.ssl_certificate, opts.ssl_key, opts.ssl_trustfile, opts.ssl_password
    if not (certificate or trustfile): return None
    domain = SSLDomain(mode)
    if trustfile:
        domain.set_trusted_ca_db(trustfile)
        domain.set_peer_authentication(SSLDomain.VERIFY_PEER, trustfile)
    if certificate:
        domain.set_credentials(certificate, key, password)
    return domain
开发者ID:ErnieAllen,项目名称:qpid-dispatch,代码行数:15,代码来源:command.py

示例5: on_start

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
 def on_start(self, event):
     self.log.debug('Container starting')
     event.container.connected = False
     if self.conf.has_option('broker', 'cert') and self.conf.has_option('broker', 'cacert'):
         ssl = SSLDomain(SSLDomain.MODE_CLIENT)
         cert = self.conf.get('broker', 'cert')
         ssl.set_credentials(cert, cert, None)
         ssl.set_trusted_ca_db(self.conf.get('broker', 'cacert'))
         ssl.set_peer_authentication(SSLDomain.VERIFY_PEER)
     else:
         ssl = None
     self.log.debug('connecting to %s', self.url)
     event.container.connect(url=self.url, reconnect=False, ssl_domain=ssl)
     connect_timeout = self.conf.getint('broker', 'connect_timeout')
     self.connect_task = event.container.schedule(connect_timeout, self)
     send_timeout = self.conf.getint('broker', 'send_timeout')
     self.timeout_task = event.container.schedule(send_timeout, self)
开发者ID:koji-project,项目名称:koji,代码行数:19,代码来源:protonmsg.py

示例6: create_ssl_domain

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
    def create_ssl_domain(self, ssl_options_dict, mode=SSLDomain.MODE_CLIENT):
        """Return proton.SSLDomain from command line options or None if no SSL options specified.
            @param opts: Parsed optoins including connection_options()
        """
        certificate, key, trustfile, password = ssl_options_dict.get('ssl-certificate'), \
                                                ssl_options_dict.get('ssl-key'), \
                                                ssl_options_dict.get('ssl-trustfile'), \
                                                ssl_options_dict.get('ssl-password')

        if not (certificate or trustfile):
            return None
        domain = SSLDomain(mode)
        if trustfile:
            domain.set_trusted_ca_db(str(trustfile))
            domain.set_peer_authentication(SSLDomain.VERIFY_PEER, str(trustfile))
        if certificate:
            domain.set_credentials(str(certificate), str(key), str(password))

        return domain
开发者ID:ajssmith,项目名称:qpid-dispatch,代码行数:21,代码来源:system_tests_user_id.py

示例7: ssl_domain

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
 def ssl_domain(connector):
     """
     Get the ssl domain using the broker settings.
     :param connector: A broker.
     :type connector: Connector
     :return: The populated domain.
     :rtype: SSLDomain
     :raise: SSLException
     :raise: ValueError
     """
     domain = None
     if connector.use_ssl():
         connector.ssl.validate()
         domain = SSLDomain(SSLDomain.MODE_CLIENT)
         domain.set_trusted_ca_db(connector.ssl.ca_certificate)
         domain.set_credentials(
             connector.ssl.client_certificate,
             connector.ssl.client_key or connector.ssl.client_certificate, None)
         if connector.ssl.host_validation:
             mode = SSLDomain.VERIFY_PEER_NAME
         else:
             mode = SSLDomain.VERIFY_PEER
         domain.set_peer_authentication(mode)
     return domain
开发者ID:darinlively,项目名称:gofer,代码行数:26,代码来源:connection.py

示例8: run

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
    def run(self):
        try:
            ssl = SSLDomain(SSLDomain.MODE_CLIENT)
            ssl.set_credentials(str(self.options.accountPublicKey), str(self.options.accountPrivateKey), str(""))
            ssl.set_trusted_ca_db(str(self.options.brokerPublicKey))
            ssl.set_peer_authentication(SSLDomain.VERIFY_PEER_NAME, trusted_CAs=str(self.options.brokerPublicKey))

            connection = BlockingConnection(self.address, ssl_domain=ssl, heartbeat=60000)
            receiver = connection.create_receiver(self.response_address)
            sender = connection.create_sender(self.request_address)

            message = Message(body="<FIXML>...</FIXML>", reply_to=self.reply_adress)
            print("-I- Sending request message: " + message.body)
            sender.send(message);

            try:
                received_message = receiver.receive(timeout=self.options.timeout)
                print("-I- Received response message: " + received_message.body)
                self.message_counter += 1
                receiver.accept()
            except Timeout, e:
                print("-I- No message received for ", self.options.timeout, " seconds")

            connection.close()
开发者ID:Eurex-Clearing-Messaging-Interfaces,项目名称:Python-Code-Examples,代码行数:26,代码来源:BlockingRequestResponse.py

示例9: sent

# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_peer_authentication [as 别名]
parser.add_option("-a", "--address", default="amqps://127.0.0.1:5672",
                  help="address to which messages are sent (default %default)")

parser.add_option("-m", "--messages", type="int", default=100,
                  help="number of messages to send (default %default)")

parser.add_option("-t", "--ssl-trustfile", default="/home/gmurthy/opensource/dispatch/tests/config-2/ca-certificate.pem",
                  help="The trust file")

parser.add_option("-c", "--ssl-certificate", default="/home/gmurthy/opensource/dispatch/tests/config-2/client-certificate.pem",
                  help="The cert file")

parser.add_option("-k", "--ssl-key", default="/home/gmurthy/opensource/dispatch/tests/config-2/client-private-key.pem",
                  help="The trust key")

parser.add_option("-p", "--ssl-password", default="client-password",
                  help="The trust file")

opts, args = parser.parse_args()

try:
    ssl_domain = SSLDomain(SSLDomain.MODE_CLIENT)
    ssl_domain.set_trusted_ca_db(str(opts.ssl_trustfile))
    ssl_domain.set_peer_authentication(SSLDomain.VERIFY_PEER, str(opts.ssl_trustfile))
    # for client authentication and private key password protected
    #ssl_domain.set_credentials(str(opts.ssl_certificate), str(opts.ssl_key), str(opts.ssl_password))
    # for client authentication and private key NOT password protected
    #ssl_domain.set_credentials(str(opts.ssl_certificate), str(opts.ssl_key), None)
    Container(Send(opts.address, opts.messages, ssl_domain=ssl_domain)).run()
except KeyboardInterrupt: pass
开发者ID:ppatierno,项目名称:qpid-dispatch-examples,代码行数:32,代码来源:simple_send_ssl.py


注:本文中的proton.SSLDomain.set_peer_authentication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。