Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd1146d0d8 | |||
| dad8cb55d7 | |||
| 6ad87ecc18 | |||
| e0e0eb5f12 | |||
| c0adefeda1 |
@@ -194,7 +194,7 @@ bool TinyMITMProxy::init()
|
||||
return false;
|
||||
}
|
||||
TINYMITM_WRITELOG(verbose, "wolfssl context creation");
|
||||
_clientCtx = wolfSSL_CTX_new(wolfTLSv1_3_client_method());
|
||||
_clientCtx = wolfSSL_CTX_new(wolfTLS_client_method());
|
||||
if (!_clientCtx)
|
||||
{
|
||||
TINYMITM_WRITELOG(error, "failed to create wolfssl context");
|
||||
@@ -435,6 +435,12 @@ void TinyMITMProxy::handleClient(SOCKET clientSocket)
|
||||
wolfSSL_set_fd(clientSSL.get(), (int)clientGuard);
|
||||
wolfSSL_set_fd(remoteSSL.get(), (int)remoteGuard);
|
||||
|
||||
char alpnList[] = "http/1.1";
|
||||
wolfSSL_UseALPN(remoteSSL.get(), alpnList, static_cast<word32>(strlen(alpnList)),
|
||||
WOLFSSL_ALPN_CONTINUE_ON_MISMATCH);
|
||||
wolfSSL_UseALPN(clientSSL.get(), alpnList, static_cast<word32>(strlen(alpnList)),
|
||||
WOLFSSL_ALPN_CONTINUE_ON_MISMATCH);
|
||||
|
||||
wolfSSL_UseSNI(remoteSSL.get(), WOLFSSL_SNI_HOST_NAME, host.c_str(), (unsigned short)host.size());
|
||||
|
||||
setNonBlocking(clientGuard, true);
|
||||
|
||||
@@ -84,12 +84,28 @@ WOLFSSL_CTX* CertificateManager::createHostContext(const std::string& host)
|
||||
cert->serial[2] = (hash >> 8) & 0xFF;
|
||||
cert->serial[3] = hash & 0xFF;
|
||||
|
||||
// SAN
|
||||
strncpy_s(reinterpret_cast<char*>(cert->altNames), sizeof(cert->altNames), hostTrimmed.c_str(), _TRUNCATE);
|
||||
cert->altNamesSz = static_cast<word16>(hostTrimmed.length());
|
||||
/*
|
||||
SAN
|
||||
*/
|
||||
memset(cert->altNames, 0, CTC_MAX_ALT_SIZE);
|
||||
|
||||
// sequence
|
||||
cert->altNames[0] = 0x30;
|
||||
cert->altNames[1] = static_cast<byte>(hostTrimmed.length() + 2);
|
||||
|
||||
//dNSName tag & len
|
||||
cert->altNames[2] = 0x82;
|
||||
cert->altNames[3] = static_cast<byte>(hostTrimmed.length());
|
||||
|
||||
// actual data
|
||||
memcpy(&cert->altNames[4], hostTrimmed.c_str(), hostTrimmed.length());
|
||||
|
||||
// sz: seq hdr (2) + dNSName hdr (2) + hostName
|
||||
cert->altNamesSz = 4 + static_cast<int>(hostTrimmed.length());
|
||||
cert->altNamesCrit = 0;
|
||||
|
||||
wc_SetSubjectKeyIdFromPublicKey(cert.get(), _sessionKey.get(), nullptr);
|
||||
wc_SetAuthKeyIdFromCert(cert.get(), _caCertDer.data(), _caCertDer.size());
|
||||
wc_SetAuthKeyIdFromCert(cert.get(), _caCertDer.data(), static_cast<int>(_caCertDer.size()));
|
||||
|
||||
/*
|
||||
cert sign
|
||||
@@ -185,8 +201,10 @@ bool CertificateManager::generateAndSaveCA(const char* caName, int days, const s
|
||||
cert->serialSz = 1;
|
||||
cert->serial[0] = 1;
|
||||
|
||||
cert->selfSigned = 1;
|
||||
|
||||
wc_SetSubjectKeyIdFromPublicKey(cert.get(), _caKey.get(), 0);
|
||||
wc_SetAuthKeyIdFromCert(cert.get(), _caCertDer.data(), _caCertDer.size());
|
||||
wc_SetAuthKeyIdFromPublicKey(cert.get(), _caKey.get(), 0);
|
||||
|
||||
/*
|
||||
CA sign
|
||||
|
||||
Reference in New Issue
Block a user