Delphi XE2 DataSnap Server - HTTPS 'Could not

2019-05-13 12:29发布

问题:

I have an existing DataSnap server (Windows service) which is running fine on HTTP, and I now want to add HTTPS as an additional protocol. I've obtained and installed an SSL certificate and generated a certificate file (.crt) and private key file (.key). As a test, when using the Delphi XE2 DataSnap Server wizard and ticking 'HTTPS' to get the certificate page, I can reference the 2 files and click the 'Test' button which succeeds. I've added an additional TDSHTTPService component and linked it to a TDSCertFiles component. In my service startup event I'm setting the path to the 2 certificate files before starting the DSServer, in the DSCertFiles.CertFile and DSCertFiles.KeyFile properties. When trying to start the service I get the error :

Could not load certificate. error:140AD002:SSL routines:SSL_CTX_use_certificate_file:system lib

Is there something I'm missing?

回答1:

Error code 0x140AD002 means SSL_CTX_use_certificate_file() was not able to open the file.



回答2:

There is a well known bug in XE2 and XE3.

I've found this workaround.

After set the TDSCert properties and before start the DSHTTPServer, call this method:

DSCertFiles2.SetServerProperties(DSHTTPService2.HttpServer); //WORK AROUND