如何在boto3资源连接中传递https_connection_factory?

How to pass https_connection_factory in boto3 resource connection?

boto3 document 中,它显示了如何将连接从 boto 2.x 迁移到 boto3

的示例
# Boto 2.x
import boto
s3_connection = boto.connect_s3()

# Boto 3
import boto3
s3 = boto3.resource('s3')

但是,in boto,可以传递一个参数https_connection_factory。 boto3 中的等价物是什么?

没有直接的等价物。创建 client or resource, you can make some very broad choices about SSL (use_ssl, verify). Both those can also take a botocore.config.Config 对象时,可以让您控制超时和 http 池行为等选项。

但是,如果您想完全控制 ssl 上下文,似乎没有任何官方支持。在内部,boto 使用 requests.Session to do all its work. You can see where the session is setup here. If you're okay with digging into botocore's internal implementation, you could reach into your resources/clients to mount a new custom Adapter for https:// paths as described in the requests user guide。 http会话对象的路径是<client>._endpoint.http_session<resource>.meta.client._endpoint.http_session.