本文整理汇总了Python中proton.SSLDomain.set_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python SSLDomain.set_credentials方法的具体用法?Python SSLDomain.set_credentials怎么用?Python SSLDomain.set_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proton.SSLDomain
的用法示例。
在下文中一共展示了SSLDomain.set_credentials方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: opts_ssl_domain
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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
示例2: is_ssl_sasl_client_accepted
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [as 别名]
def is_ssl_sasl_client_accepted(self, listener_port, tls_protocol):
"""
Attempts to connect a proton client to the management address
on the given listener_port using the specific tls_protocol provided.
If connection was established and accepted, returns True and False otherwise.
:param listener_port:
:param tls_protocol:
:return:
"""
# Management address to connect using the given TLS protocol
url = Url("amqps://0.0.0.0:%d/$management" % listener_port)
# Preparing SSLDomain (client cert) and SASL authentication info
domain = SSLDomain(SSLDomain.MODE_CLIENT)
domain.set_credentials(self.ssl_file('client-certificate.pem'),
self.ssl_file('client-private-key.pem'),
'client-password')
# Enforcing given TLS protocol
cproton.pn_ssl_domain_set_protocols(domain._domain, tls_protocol)
# Try opening the secure and authenticated connection
try:
connection = BlockingConnection(url,
sasl_enabled=True,
ssl_domain=domain,
allowed_mechs='PLAIN',
user='[email protected]',
password='password')
except proton.ConnectionException:
return False
# TLS version provided was accepted
connection.close()
return True
示例3: run
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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
示例4: on_start
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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
示例5: SSLConfig
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [as 别名]
class SSLConfig(object):
def __init__(self):
self.client = SSLDomain(SSLDomain.MODE_CLIENT)
self.server = SSLDomain(SSLDomain.MODE_SERVER)
def set_credentials(self, cert_file, key_file, password):
self.client.set_credentials(cert_file, key_file, password)
self.server.set_credentials(cert_file, key_file, password)
def set_trusted_ca_db(self, certificate_db):
self.client.set_trusted_ca_db(certificate_db)
self.server.set_trusted_ca_db(certificate_db)
示例6: opts_ssl_domain
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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
示例7: on_start
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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)
示例8: create_ssl_domain
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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
示例9: ssl_domain
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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
示例10: run
# 需要导入模块: from proton import SSLDomain [as 别名]
# 或者: from proton.SSLDomain import set_credentials [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