dart:io
库中SecurityContext.setTrustedCertificates
方法的用法介绍如下。
用法:
void setTrustedCertificates(
String file,
{String? password}
)
将证书添加到 SecureSocket 客户端连接使用的可信 X509 证书集。
file
是包含 X509 证书的 PEM 或 PKCS12 文件的路径,通常是来自证书颁发机构的根证书。对于 PKCS12 文件,password
是文件的密码。对于 PEM 文件,password
被忽略。假设它是well-formatted,则file
的所有其他内容都将被忽略。
注意:此函数调用 File.readAsBytesSync ,并将阻塞文件 IO。更喜欢使用 setTrustedCertificatesBytes 。
iOS 注意:在 iOS 上,此调用仅使用单个 DER 编码的 X509 证书的字节。它可能会被多次调用以将多个受信任的证书添加到上下文中。可以使用 openssl 工具从 PEM 编码的证书中获取 DER 编码的证书:
$ openssl x509 -outform der -in cert.pem -out cert.der
相关用法
- Dart SecureSocket.connect用法及代码示例
- Dart SecureSocket.secure用法及代码示例
- Dart SetMixin.forEach用法及代码示例
- Dart SetMixin.addAll用法及代码示例
- Dart Set.removeWhere用法及代码示例
- Dart Set.from用法及代码示例
- Dart SetMixin.reduce用法及代码示例
- Dart Set.remove用法及代码示例
- Dart Set.retainAll用法及代码示例
- Dart SetMixin.removeAll用法及代码示例
- Dart SetMixin.add用法及代码示例
- Dart SetMixin.expand用法及代码示例
- Dart SetMixin.elementAt用法及代码示例
- Dart SetMixin.contains用法及代码示例
- Dart Set.contains用法及代码示例
- Dart SetMixin.containsAll用法及代码示例
- Dart Set.retainWhere用法及代码示例
- Dart Set.union用法及代码示例
- Dart Set.unmodifiable用法及代码示例
- Dart SetMixin.isEmpty用法及代码示例
- Dart SetMixin.firstWhere用法及代码示例
- Dart Set.addAll用法及代码示例
- Dart SetMixin.skip用法及代码示例
- Dart Set.difference用法及代码示例
- Dart Set.clear用法及代码示例
注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 setTrustedCertificates method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。