![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
|||
|
|||
|
Hola.
He intentado usar la función pero me sale este error. ¿Sabéis como poder solucionarlo? Error connecting with SSL. error 1409442E:SSL routines:SSL3_READ_BYTES: tlsv 1 alert protocol version Gracias!!!! |
|
#2
|
|||
|
|||
|
prueba con este: A mi me funciona correctamente en delphi 7
Código:
unit Unit2;
interface
uses
Windows, SysUtils, IdHTTP, IdSSLOpenSSL, DateUtils;
function LeeFechaHoraInternet: string;
implementation
function GetTimeZoneOffset: TDateTime;
var
TZInfo: TTimeZoneInformation;
Bias: Integer;
begin
case GetTimeZoneInformation(TZInfo) of
TIME_ZONE_ID_STANDARD, TIME_ZONE_ID_DAYLIGHT:
Bias := TZInfo.Bias + TZInfo.DaylightBias; // Ajuste según horario de verano
else
Bias := 0; // Si no se puede determinar la zona horaria, se asume UTC
end;
Result := Bias / MinsPerDay; // Convertir minutos a días
end;
function LeeFechaHoraInternet: string;
var
Http: TIdHTTP;
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
Respuesta: string;
UnixTicks: Int64;
FechaHoraUTC, FechaHoraLocal: TDateTime;
TimeZoneOffset: TDateTime;
begin
Result := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss"Z"', Now); // Valor predeterminado
Http := TIdHTTP.Create(nil);
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
try
SSLHandler.SSLOptions.Method := sslvTLSv1_2; // Usar TLS 1.2
SSLHandler.SSLOptions.SSLVersions := [sslvTLSv1_2];
SSLHandler.SSLOptions.Mode := sslmClient; // Modo cliente
// Configurar cliente con este manejador SSL
// IdHTTP1.IOHandler := SSLHandler;
// IdHTTP1.Request.UserAgent := 'Mozilla/5.0';
// Realiza la conexión HTTP/HTTPS
// IdHTTP1.Get('https://yourserver.com');
Http.IOHandler := SSLHandler;
Http.Request.Accept := 'application/json';
Http.Request.UserAgent := 'Mozilla/5.0 (compatible; Delphi)';
try
// Realizar la solicitud HTTP
Respuesta := Http.Get('https://www2.roa.es/cgi-bin/horautc');
// Respuesta := Http.Get('https://www.google.com');
// Convertir la respuesta (ticks Unix) a DateTime
UnixTicks := StrToInt64(Trim(Respuesta));
FechaHoraUTC := UnixDateDelta + (UnixTicks div SecsPerDay) + (UnixTicks mod SecsPerDay) / SecsPerDay;
// Obtener el desfase horario
TimeZoneOffset := GetTimeZoneOffset;
FechaHoraLocal := FechaHoraUTC - TimeZoneOffset;
// Devolver la fecha y hora en formato ISO 8601
Result := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss"Z"', FechaHoraLocal);
except
on E: Exception do
// En caso de error, devolver la hora actual
result := E.Message;
// Result := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss"Z"', Now);
end;
finally
Http.Free;
SSLHandler.Free;
end;
end;
end.
|
|
#3
|
|||
|
|||
|
Gracias por la respuesta tan rápida.
He probado el código y en la línea "Respuesta := Http.Get('https://www2.roa.es/cgi-bin/horautc');" me sigue saliendo el error. Me da que hay algún problema de compatibilidad de versiones de SSL o algo así. Un saludo. |
|
#4
|
|||
|
|||
|
Desactiva el antivirus y prueba
|
|
#5
|
|||
|
|||
|
La dll que estoy usando son :ssleay32.dll version 1.0.2.21
libeay32.dll version 1.0.2.21 |
|
#6
|
|||
|
|||
|
En delphi con Indy tiene cuatro protocolos distintos para hacerlo de una manera mucho mas sencilla y ademas te sincroniza la hora con el PC.
Os pongo un ejemplo de dos de ellos con TidTimeUDP y TidSNTP:
Última edición por delphiGar fecha: 07-12-2024 a las 14:57:37. |
|
#7
|
|||
|
|||
|
Hola.
He probado el código y funciona de maravilla. Solo que hay que ejecutar la aplicación en modo administrador. Seguiré investigando el error "connecting with SSL. error 1409442E:SSL routines:SSL3_READ_BYTES: tlsv 1 alert protocol version" Muchas gracias. |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| TimeStamp | Willo | MySQL | 4 | 22-03-2016 21:15:00 |
| Consulta TimeStamp | Jose Roman | SQL | 2 | 06-09-2012 04:03:11 |
| TimeStamp = TimeStamp me da error | Chogo | Firebird e Interbase | 7 | 16-03-2011 04:13:38 |
| TIMESTAMP en restriccion | Cañones | SQL | 6 | 28-08-2007 23:19:27 |
| Timestamp y bde 5.2 | Toni | Firebird e Interbase | 2 | 27-05-2003 09:26:33 |
|