迁移到10.4 Sydney后,Delphi Indy SSL错误

问题描述 投票:1回答:1

用Delphi 10.4编译完Win32客户端/服务器应用程序(使用INDY和TMS Sparkle)后,出现ssl错误。我在服务器端使用Indy和自签名证书,在客户端使用indy。错误消息是(从德语翻译):

与SSL的错误连接。 EOF遇到违反协议的情况。

我没有更改10.3完美运行的任何代码或环境。我可以将其分解为服务器端,因为旧服务器(在10.3中编译)与新客户端(与10.4一起编译)一起运行,但是旧客户端在尝试连接到新服务器时也会中断。

这是我初始化SSL的方式:

    SecureServer := TIndySparkleHTTPServer.create(nil);
    SecureServer.DefaultPort := SecurePort;
    // Initialize SSL with self signed certificate
    SSLHandler := TIdServerIOHandlerSSLOpenSSL.create(SecureServer);
    SSLHandler.SSLOptions.CertFile := SharedVals.ServerPath + 'appcert.pem';
    SSLHandler.SSLOptions.RootCertFile := SharedVals.ServerPath + 'approot.pem';
    SSLHandler.SSLOptions.KeyFile := SharedVals.ServerPath + 'appkey.pem';
    SSLHandler.SSLOptions.Method := sslvSSLv23;
    SecureServer.IOHandler := SSLHandler;

Emba设法在10.3中打破了Indy,也许这是另一个这样的情况?

delphi ssl indy
1个回答
0
投票

该信用归雷米·勒鲍(Remy Lebau)所指,他为我指明了正确的方向。但是我想通过提供使它在Delphi 10.4中再次起作用的代码来回答我的问题。由于Indy的更改是在2018年完成的(!),我仍然不知道为什么在升级到10.4之前它在10.3中可以完美运行。

由于我直接在服务/守护程序项目中使用了用于Indy的TMS Sparke Server,所以我提供了一个小类来连接需要对象方法的OnQuerySSLPort方法。

type
  TSSLHelper = class
  // This helper class is neccessary to set ssl true
  // as it defaults to false on non standard ssl ports
    procedure QuerySSLPort(APort: Word; var VUseSSL: boolean);
  end;

...

procedure TSSLHelper.QuerySSLPort(APort: Word; var VUseSSL: boolean);
begin
  VUseSSL := true;
end;

...

SecureServer := TIndySparkleHTTPServer.create(nil);
SecureServer.DefaultPort := SecurePort;
// Initialize SSL with self signed certificate
SSLHandler := TIdServerIOHandlerSSLOpenSSL.create(SecureServer);
SSLHandler.SSLOptions.CertFile := SharedVals.ServerPath + 'appcert.pem';
SSLHandler.SSLOptions.RootCertFile := SharedVals.ServerPath + 'approot.pem';
SSLHandler.SSLOptions.KeyFile := SharedVals.ServerPath + 'appkey.pem';
SSLHandler.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
SecureServer.IOHandler := SSLHandler;
SSLHelper := TSSLHelper.Create;
SecureServer.OnQuerySSLPort := SSLHelper.QuerySSLPort;
...

现在它像以前一样工作。

© www.soinside.com 2019 - 2024. All rights reserved.