构建安全备份系统:从数据传输到存储的全方位保障
1. 安全的数据传输:HTTPS 连接检查
在与 Windows Azure 存储服务进行通信时,为了确保数据在传输过程中的安全性,我们可以使用 HTTPS 连接。以下是一段示例代码,展示了如何创建一个安全的 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