Last active
March 12, 2024 14:56
-
-
Save wellington1993/2cc0078f9eca86a3b6a5ab9c3d4d17b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses | |
IdHTTP, IdSSLOpenSSL, IdGlobal, System.Classes; | |
function CreateIdHTTPComponent(AOwner: TComponent = nil; const Url: string = ''): TIdHTTP; | |
var | |
SSLio: TIdSSLIOHandlerSocketOpenSSL; | |
begin | |
// Cria o componente TIdHTTP com o Owner especificado | |
Result := TIdHTTP.Create(AOwner); | |
Result.HandleRedirects := true; | |
// Se a URL for fornecida e começar com 'https', configure o componente para usar SSL/TLS | |
if (Url = '') or (LowerCase(URIProtocol(Url)) = 'https') then | |
begin | |
SSLio := TIdSSLIOHandlerSocketOpenSSL.Create(Result); | |
SSLio.SSLOptions.Mode := sslmClient; // Define o modo como cliente | |
SSLio.SSLOptions.Method := sslvTLSv1_2; | |
SSLio.SSLOptions.SSLVersions := [sslvTLSv1_2, sslvTLSv1_1, sslvTLSv1]; | |
Result.IOHandler := SSLio; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment