首页 > 解决方案 > Flutter 客户端证书认证

问题描述

我正在使用配置为需要客户端证书以允许客户端连接的 WCF 服务。我用邮递员测试了所有东西,服务运行良好。如果我尝试使用颤振客户端进行身份验证,就会出现问题。当然我用的是https。

我试过了

var clientCertificate = (await rootBundle.load('lib/assets/certificates/clientAuthenticationCert.pfx')).buffer.asInt8List();
securityContext.useCertificateChainBytes(clientCertificate, password: "test");
securityContext.usePrivateKeyBytes(clientCertificate, password: "test");
HttpClient httpsClient = HttpClient(context: securityContext);
IOClient httpTest = new IOClient(httpsClient);
http.Response response = await httpTest.post(kIsWeb ? Uri.parse(_serviceEndpointWithProxy) : Uri.parse(_ServiceEndpoint),
    headers: {
      "Content-Type": "text/xml; charset=utf-8",
      "SOAPAction": "http://someUrl/someService/${action}",
      "Host": "someService.someUrl.net",
      "Accept": "*/*",
      "Accept-Encoding": "gzip, deflate, br",
      "Content-Length": utf8.encode(envelope).length.toString(),
    },
    body: envelope,
    encoding: Encoding.getByName("utf-8"));

但不幸的是,它抛出了一个例外,没有任何进一步的细节。

任何想法如何使用客户端证书身份验证和颤振?提前致谢

标签: flutterdartauthenticationcertificateclient

解决方案


推荐阅读