feat: handle certs based on config
This commit is contained in:
@@ -140,6 +140,24 @@ bool TinyMITMProxy::init()
|
||||
},
|
||||
nullptr);
|
||||
|
||||
bool hasCA = false;
|
||||
if (_config.autoGenerateCA)
|
||||
{
|
||||
if (!_certManager.loadCA(_config.customCaCertDer.c_str(), _config.customCaKeyDer.c_str()))
|
||||
hasCA = _certManager.generateAndSaveCA(_config.caName.c_str(), _config.caDays, _config.caCertPath,
|
||||
_config.caKeyPath);
|
||||
else
|
||||
hasCA = true;
|
||||
}
|
||||
else
|
||||
hasCA = _certManager.loadCA(_config.customCaCertDer.c_str(), _config.customCaKeyDer.c_str());
|
||||
|
||||
if (!hasCA) return false;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (_config.installToSystemStore) _certManager.installCertificate();
|
||||
#endif
|
||||
|
||||
// socket setup
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
@@ -149,7 +167,6 @@ bool TinyMITMProxy::init()
|
||||
_listenSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
sockaddr_in addr{};
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(_port);
|
||||
addr.sin_port = htons(_config.port);
|
||||
addr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user