构建安全备份系统的技术指南
1. 建立安全的 HTTPS 连接
在与 Windows Azure 存储服务通信时,为确保数据传输的安全性,我们可以使用 HTTPS 连接。以下是一段 Python 代码示例,展示了如何创建一个安全的 HTTPS 连接:
# Create a connection object
if USE_HTTPS:
ctx = SSL.Context()
# Verify that the server chains to a known CA.
# We hardcode cacerts.pem in the source directory
# with GTE CyberTrust's certs which is what
# Windows Azure chains to currently.
ctx.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, 9)
# GTE's certs are kept in cacerts.pem in the same directory
# as source. sys.path[0] always
# contains the directory in which the source file exists
if ctx.load_verify_locations(sys.path[0] + "/cacerts.pem")!=1:
raise Exception("No CA certs")
超级会员免费看
订阅专栏 解锁全文
11万+

被折叠的 条评论
为什么被折叠?



