I need to use TIdHTTP to request an HTTPS URL for an IP address on an SSL connection, so certificate validation will fail (if the peer even has a cert).
curl has the -insecure parameter and it works just fine, but I can't find anything in TIdHTTP to accomplish the same thing.
SSESocket := TIdHTTP.Create;
SSESocket.Request.Accept := 'text/event-stream';
SSESocket.Request.CacheControl := 'no-store';
SSESocket.Get('https://'+Host+'/eventstream/clip/v2', SSEventStream);
What am I missing?
You can explicitly assign a
TIdSSLIOHandlerSocketOpenSSLcomponent to theTIdHTTP.IOHandlerproperty, and then you can set the IOHandler'sSSLOptions.VerifyModeproperty to[]and itsSSLOptions.VerifyDepthproperty to 0.In your example,
TIdHTTPis implicitly creating an internalTIdSSLIOHandlerSocketOpenSSLwith default settings for you.You can optionally also assign a handler to the
TIdSSLIOHandlerSocketOpenSSL.OnVerifyPeerevent and have it returnTrueto accept the server's certificate, regardless of whether OpenSSL would normally reject it.