File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919#include < spdlog/cfg/env.h>
2020
2121#include < thread>
22+ #include < cassert>
2223
2324#include " httpserver.h"
2425#include " dns.h"
@@ -112,8 +113,9 @@ int main(int argc, char **argv)
112113 spdlog::debug (" 线程{}退出成功" , i);
113114 }
114115 };
116+ auto core_size=std::thread::hardware_concurrency ()%32 ;
115117 // 为了防止对象在多线程情况下销毁出问题
116- std::jthread t (create_thread, create_thread, 1 );
118+ std::jthread t (create_thread, create_thread, core_size );
117119
118120 io_context.run ();
119121 }
Original file line number Diff line number Diff line change @@ -69,9 +69,10 @@ namespace hcpp
6969 }
7070 // 可以根据需要处理其他类型的Subject Alternative Name
7171 }
72+ // XXX 一般服务器会发送证书链,包含多个证书,也就是校验函数会被调用多次
73+ // 我们只对这些有主体名(SAN)的证书创建假证书
74+ pci.pubkey_ = make_pem_str (X509_get_X509_PUBKEY (cert));
7275 }
73-
74- pci.pubkey_ = make_pem_str (X509_get_X509_PUBKEY (cert));
7576 return true ;
7677 }
7778 else
@@ -81,7 +82,7 @@ namespace hcpp
8182 // X509_NAME_oneline(X509_get_subject_name(cert), subject_name, sizeof(subject_name)); });
8283 };
8384 }
84-
85+
8586 awaitable<void > mitm_svc::make_memory (std::string svc_host, std::string svc_service)
8687 {
8788 try
@@ -105,7 +106,6 @@ namespace hcpp
105106 {
106107 if (verify_fun)
107108 {
108- log::info (" mitm_svc::make_memory: 校验{}开始" , host);
109109 return verify_fun (preverified, v_ctx);
110110 }
111111 return true ;
Original file line number Diff line number Diff line change 1- // BUG 复现三次校验证书
1+ // XXX 复现三次校验证书
2+ // 注意 这不是bug,因为服务器会发送不止一个证书
3+ // 可能设置其他校验规则,例如,校验深度 会改变校验三次的情况
24
35#include < asio/ssl.hpp>
46#include < asio/ip/tcp.hpp>
@@ -34,7 +36,7 @@ struct endpoint
3436inline std::optional<endpoint> check_http_url (std::string url)
3537{
3638 // thread_local static std::regex re{R"(^https?://([^/]+)/.*)"};
37- thread_local static std::regex re{R"( (https?)://([^/]+)(?::(\d+))?(/.*)?)" };
39+ thread_local static std::regex re{R"( (https?)://([^/: ]+)(?::(\d+))?(/.*)?)" };
3840 std::smatch sm;
3941 endpoint ep{};
4042 if (std::regex_search (url, sm, re))
You can’t perform that action at this time.
0 commit comments