@yoonit/nativescript-handshake
为 Android 和 iOS 实现动态 SSL 指纹固定的 NativeScript NPM。
npm i --save @yoonit/nativescript-handshake

nativescript-yoonit-handshake

为 Android 和 iOS 实现动态 SSL 指纹固定的 NativeScript NPM。

关于

SSL 指纹固定是一种减轻针对安全 HTTP 通信的中间人攻击的技术,但它有一个缺点,即证书的过期日期。此方法解决了这个问题,实现了动态 SSL 指纹固定,在 TLS 握手过程中提供了易于使用的指纹验证。远程服务器必须负责更新证书(s)。

安装

npm i -s @yoonit/nativescript-handshake  

特别感谢和致谢...

库的当前版本依赖于 [Wultra SSL Pinning] ([Android](https://github.com/wultra/ssl-pinning-android) 和 [iOS](https://github.com/wultra/ssl-pinning-ios)))。

使用方法

function updateFingerprint() {
this.$yoo.handshake.updateFingerprints(
"YOUR PUBLIC KEY",
"YOUR SERVICE URL",
(result) => {
switch (result) {
case HandshakeResult.OK:
// - Everything is OK;
// - No Action is required;
return;

case HandshakeResult.STORE_IS_EMPTY:
// - The update request succeeded;
// - Result is still an empty list of certificates;
// - May loading & validating of remote data succeeded;
// - All loaded certificates are already expired;"
return;

case HandshakeResult.NETWORK_ERROR:
// - The update request failed on a network communication.
return;

case HandshakeResult.INVALID_DATA:
// The update request returned the data which did not pass the signature validation.
return;

case HandshakeResult.INVALID_SIGNATURE:
// The update request returned the data which did not pass the signature validation.
return;

case HandshakeResult.INVALID_URL_SERVICE:
// The url service does not exist or is invalid.
return;
}
}
);
}

API

方法

功能 参数 描述
updateFingerprint publicKey: string, serviceUrl: string, callback: (result: string) => void 从远程服务器更新指纹列表。该方法是非同步的。响应可以在回调中获取。

握手结果

HandshakeResult 描述
"OK"
  • 一切正常;
  • 不需要采取任何行动;
STORE_IS_EMPTY"
  • 更新请求成功;
  • 结果仍然是一个空的证书列表;
  • 可能已成功加载并验证远程数据;
  • 所有加载的证书都已过期;
  • 所有加载的证书都已过期;
"NETWORK_ERROR" 更新请求在网络通信中失败。
"INVALID_DATA" 更新请求返回了未通过签名验证的数据。
"INVALID_SIGNATURE" 更新请求返回了未通过签名验证的数据。
"INVALID_URL_SERVICE" URL 服务不存在或不有效。

贡献并使其变得更好

克隆仓库,更改所需内容并发送 PR。

对于提交信息,我们使用 常规提交

欢迎贡献!


Cyberlabs AI 前端团队用 ❤ 编写代码