首页 > 解决方案 > 如何将 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 文件是有效的,但应用程序会给出一个错误,表明它不是有效的证书。

有人有一个可行的例子吗?

标签: delphiipworksnsoftware

解决方案


根据 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

推荐阅读