delphi - 如何将 IPWorks 与自签名 SSL 证书一起使用?
问题描述
我正在尝试找到一种方法来使用/n Software 的 IPWorks服务器/客户端组件和自签名 SSL 证书。
我在客户端尝试这个:
cl.SSLCertStoreType := cstPFXFile;
cl.SSLCertStore := 'cert.pfx';
cl.SSLCertStorePassword := 'password';
cl.Connect('localhost',5050);
这在服务器端:
server.SSLCertStoreType := cstPFXFile;
server.SSLCertStore := 'cert.pfx';
server.SSLCertStorePassword := 'password';
server.LocalPort:= 5050;
server.SSLEnabled:=true;
server.Listening := true;
PFX 文件是有效的,但应用程序会给出一个错误,表明它不是有效的证书。
有人有一个可行的例子吗?
解决方案
根据 IPWorks 网站上的此文档,可以使用同一 IPWorks 库提供的 CertMgr 类生成自签名证书。
https://www.nsoftware.com/kb/xml/11080101.rst
要生成证书,只需调用 IPWorks SSL 中包含的 CertMgr 组件的 CreateCertificate 方法。此方法将主题和序列号作为参数:
CertMgr1.CreateCertificate "CN=我的证书主题", 0000001
Certmgr certMgr1 = new Certmgr();
certMgr1.RuntimeLicense = ""; //Assign your license, otherwise you'll get exception
certMgr1.CreateCertificate("CN=My Cert Subject", 000001);
//Use certMgr1.Cert property to use generated Self-signed certificate
推荐阅读
- python - 反之亦然列出超出范围的索引
- unity3d - 如何提高实例化对象的生成速度?
- php - 干预图像上传到laravel中的mysql数据库显示以下错误
- html - 在同一窗口上显示图像作为弹出窗口
- python - 无法预测测试数据时间序列 ARIMA
- javascript - 图表JS背景颜色线被注释重叠
- javascript - 如果我已经在使用 useEfeck 挂钩,如何更新我的 useState 变量?
- r - 根据 R 中 data.table 中的日期选择半最后的观察结果
- google-drive-api - Google 云端硬盘不知道要冒充哪个用户
- c++ - 无法弄清楚如何使用 C++ 中的链表按从 a 到 z 的顺序显示字母