Delphi XE2 DataSnap Server - HTTPS 'Could not load certificate'

[亡魂溺海] 提交于 2019-12-07 15:32:57

问题


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


来源:https://stackoverflow.com/questions/9011628/delphi-xe2-datasnap-server-https-could-not-load-certificate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!