dehphi 10 seattle
Indy版本:10.6.2.5298
SSL版本:OpenSSL 1.0.0d 8 Feb 2011
调https时出现以下错误 :
没有带证书报以下错误 :
First chance exception at $75460D72. Exception class EIdOSSLUnderlyingCryptoError with message
'Error connecting with SSL.
error:14094438:SSL routines:SSL3_READ_BYTES:tlsv1 alert internal error'.
Process Project1.exe (6288)
带有证书报:
First chance exception at $75460D72. Exception class EIdOSSLLoadingCertError with message
'Could not load certificate.
error:00000000:lib(0):func(0):reason(0)'.
Process Project1.exe (6288)
Method:sslvTLSv1_2 每一种都 试了
Mode:sslmClient 每一种都 试了
dll:ssleay32 我是官网1.0.0d 8 包里面的,应是没问题 的
不知道是服务器还需要配置什么还是我的SSL库有问题
请帮忙分析下原因,万分感谢!
procedure TForm_main.PostJSON(const AURL, AJSON: string);
var
HTTP: TIdHTTP;
JSONData: TStringList;
Response: string;
begin
HTTP := TIdHTTP.Create(nil);
JSONData := TStringList.Create;
try
// 设置SSL/TLS选项
HTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP);
TIdSSLIOHandlerSocketOpenSSL(HTTP.IOHandler).SSLOptions.Method := sslvTLSv1_2;// sslvTLSv1_2;
TIdSSLIOHandlerSocketOpenSSL(HTTP.IOHandler).SSLOptions.SSLVersions := [sslvTLSv1_2];//[sslvTLSv1_2];
TIdSSLIOHandlerSocketOpenSSL(HTTP.IOHandler).SSLOptions.Mode := sslmClient;
TIdSSLIOHandlerSocketOpenSSL(HTTP.IOHandler).SSLOptions.CertFile := 'cx.zdytsl.com_nginx\sycx.zdytsl.com.pem'; // 客户端SSL证书文件路径
TIdSSLIOHandlerSocketOpenSSL(HTTP.IOHandler).SSLOptions.KeyFile := 'cx.zdytsl.com_nginx\sycx.zdytsl.com.key'; // 客户端SSL证书私钥文件路径
//TIdSSLIOHandlerSocketOpenSSL(HTTP.IOHandler).SSLOptions.RootCertFile := 'cx.zdytsl.com_nginx\sycx.zdytsl.com.pem'; // CA根证书文件路径
HTTP.HandleRedirects := true;
// 将JSON字符串添加到TStringList
JSONData.Text := AJSON;
// 发送POST请求
Response := HTTP.Post(AURL, JSONData);
// 处理响应
ShowMessage(Response);
finally
JSONData.Free;
HTTP.Free;
end;
end;