安卓签名证书

This commit is contained in:
wanghongenpin
2023-11-22 16:20:25 +08:00
parent 2f2e5b405b
commit 08decff829
12 changed files with 216 additions and 101 deletions

View File

@@ -92,7 +92,6 @@ class Network {
}
String? host = hostAndPort?.host;
host ??= TLS.getDomain(data);
//ssl自签证书
var certificate = await CertificateManager.getCertificateContext(host!);
//服务端等待客户端ssl握手

View File

@@ -1,6 +1,32 @@
/*
* Copyright 2023 WangHongEn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'dart:typed_data';
class TLS {
///判断是否是TLS Client Hello
static bool isTLSClientHello(Uint8List data) {
if (data.length < 43) return false;
if (data[0] != 0x16 /* handshake */) return false;
if (data[1] != 0x03 || data[2] < 0x00 || data[2] > 0x03) return false;
if (data[5] != 0x01 /* client_hello */) return false;
if (data[9] != 0x03 || data[10] < 0x00 || data[10] > 0x03) return false;
return true;
}
///从TLS Client Hello 解析域名
static String? getDomain(Uint8List data) {
try {