Python 官方文档:入门教程 => 点击学习
1.配置IIS 2.客户端安装SSL访问WEB服务器 #!/usr/bin/env python import Socket, sys def sendall(s, buf): byteswritten = 0 wh
1.配置IIS
#!/usr/bin/env python
import Socket, sys
def sendall(s, buf):
byteswritten = 0
while byteswritten < len(buf):
byteswritten += s.write(buf[byteswritten:])
print "Creating socket...",
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "done."
print "Connecting to remote host...",
s.connect(("127.0.0.1", 443))
print "done."
print "Establishing SSL...",
ssl = socket.ssl(s)
print "done."
print "Requesting document...",
sendall(ssl, "GET / Http/1.0\r\n\r\n")
print "done."
s.shutdown(1)
while 1:
try:
buf = ssl.read(1024)
except socket.sslerror, err:
if (err[0]) in [socket.SSL_ERROR_ZERO_RETURN, socket.SSL_ERROR_EOF]:
break
elif (err[0]) in [socket.SSL_ERROR_WANT_READ,
socket.SSL_ERROR_WANT_WRITE]:
continue
raise
if len(buf) == 0:
break
sys.stdout.write(buf)
s.close()
--结束END--
本文标题: Python内置ssl模块编程(1)
本文链接: https://lsjlt.com/news/191665.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0