【问题标题】:ionic framework / ionic native http: ssl client based authentification离子框架/离子原生http:基于ssl客户端的身份验证
【发布时间】:2018-05-03 11:18:39
【问题描述】:

我指的是这个问题:https://forum.ionicframework.com/t/ionic-native-http-ssl-client-based-authentification/129596

任何想法如何在 ionic 框架内实现基于 ssl 客户端的身份验证(相互 tls)?我使用离子原生 http 插件。我将 .cer 文件放在了platforms/android/asset 文件夹中。

this.http.acceptAllCerts(true);
this.http.enableSSLPinning(false);

this.http.get('https://someip/backend/all', {}, {})
  .then(data => {
    console.log("data",data)
  })
  .catch(error => {
    console.log("error",error);
  });

目前,http 请求并未随每个请求发送所需的 ssl 证书。

<html>
<head><title>400 No required SSL certificate was sent</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>No required SSL certificate was sent</center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>

使用 angular/http 发送 http 请求时同样的问题

离子信息

cli packages: (C:\Users\myname\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

全局包:

cordova (Cordova CLI) : not installed

本地包:

@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 6.3.0 browser 5.0.0
Ionic Framework    : ionic-angular 3.9.2

系统:

Android SDK Tools : 26.1.1
Node              : v6.11.3
npm               : 3.10.10
OS                : Windows 10

环境变量:

ANDROID_HOME : C:\Users\myname\Android\sdk

杂项:

backend : pro

【问题讨论】:

  • 您需要添加更多信息,请使用ionic info => 您要使用哪个平台?
  • 我添加了请求的离子信息输出,我正在尝试构建一个使用基于客户端的 ssl 身份验证的 android apk。问题是如何发送包含我的证书的 http 请求(格式 .p12 或其他)

标签: ssl ionic-framework https ionic-native mutual-authentication


【解决方案1】:

对于 Android,我使用安装了插件“cordova-client-cert-authentication”的 Cordova,这立即起作用:安装插件并编译应用程序后,它会在应用程序运行后立即询问要使用的证书开始并且请求按预期工作。

这确实需要您在手机的身份存储中安装证书,这会强制您在设备上启用锁屏。

【讨论】:

  • 我可以确认这一点,使用 cordova-client-cert-authentication 插件解决了这个问题
猜你喜欢
  • 2018-07-03
  • 2021-11-22
  • 2016-06-08
  • 2017-08-03
  • 1970-01-01
  • 2012-07-19
  • 1970-01-01
  • 2021-06-05
  • 1970-01-01
相关资源
最近更新 更多