import os.path
import socket
from tlslite.api import *
lsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address = ("localhost", 4443)
lsock.bind(address)
lsock.listen(5)
connection = TLSConnection(lsock.accept()[0])
dir="."
x509Cert = X509().parse(open(os.path.join(dir, "serverX509Cert.pem")).read())
x509Chain = X509CertChain([x509Cert])
s = open(os.path.join(dir, "serverX509Key.pem")).read()
x509Key = parsePEMKey(s, private=True)
#
settings = HandshakeSettings()
settings.minVersion = (3,0)
settings.maxVersion = (3,0)
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key, reqCert=True, settings=settings)
#
#connection.handshakeServer(certChain=x509Chain, privateKey=x509Key, reqCert=True)
print "Test 14 - good mutual X.509"
assert(isinstance(connection.session.serverCertChain, X509CertChain))
connection.close()
connection.sock.close()
import os.path
import socket
from tlslite.api import *
def connect():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if hasattr(sock, 'settimeout'): #It's a python 2.3 feature
sock.settimeout(5)
address = ("localhost", 4443)
sock.connect(address)
c = TLSConnection(sock)
return c
connection = connect()
dir="."
print "Test 14 - good mutual X509"
x509Cert = X509().parse(open(os.path.join(dir, "clientX509Cert.pem")).read())
x509Chain = X509CertChain([x509Cert])
s = open(os.path.join(dir, "clientX509Key.pem")).read()
x509Key = parsePEMKey(s, private=True)
#
settings = HandshakeSettings()
settings.minVersion = (3,0)
settings.maxVersion = (3,0)
connection.handshakeClientCert(x509Chain, x509Key, settings=settings)
#
#connection.handshakeClientCert(x509Chain, x509Key)
assert(isinstance(connection.session.serverCertChain, X509CertChain))
connection.close()
connection.sock.close()
分享到:
相关推荐
"tlslite-0.3.8.zip" 是一个压缩包文件,其名称表明它包含了“tlslite”的一个特定版本——0.3.8。"tlslite"是一个软件库,可能是一个Python编程语言的库。 **描述详解:** 描述指出“TLS Lite”是一个免费的Python...
例子 以下示例来自examples/sni.rs 尝试使用cargo run --example sni 。 通常,提供的字节将来自TCP套接字。 出于演示目的,它们是内联提供的。 extern crate tls_client_hello; use tls_client_hello
tlsfuzzer tlsfuzzer是针对SSLv2,SSLv3,TLS 1.0,TLS 1.1,TLS 1.2和TLS 1.3实施的测试套件。... python模块(依赖tlslite-ng的软件,应自动安装),至少使用0.15版以获得最佳性能 (可选)为使密码计算
AppEngine 上的套接字池一种在 Google AppEngine Python 上重用出站套接字的有效且可... 为此,我们使用 TLSlite 库和 sha1 和 md5 的纯 Python 实现。 因此,我们在这里牺牲了速度,但与将任务排入队列并稍后处理它们