5,388
社区成员
发帖
与我相关
我的任务
分享
IdHTTPServer1.Bindings.Clear;
IdHTTPServer1.DefaultPort:= 443;
IdHTTPServer1.Bindings.Add.IP := '127.0.0.1';
IdHTTPServer1.IOHandler:=IdServerIOHandlerSSLOpenSSL1;
//启动服务器
IdHTTPServer1.Active := True;
procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
memo1.Lines.Add(ARequestInfo.Document) ;
end;
//idsrvrhndlrslpnsl1.OnGetPassword:=GetPassword;
//procedure TForm1.GetPassword(var strPassword:string);
//begin
// strPassword:='zyyzyy';
//end;
难道不需要赋值证书文件的密码吗?
//idsrvrhndlrslpnsl1.OnGetPassword:=GetPassword;
//procedure TForm1.GetPassword(var strPassword:string);
//begin
// strPassword:='zyyzyy';
//end;
难道不需要赋值证书文件的密码吗?[/quote]
你试试看能不能正常访问呢
procedure TForm1.idsrvrhndlrsl1GetPassword(var Password: String);
begin
Password:='zyyzyy';
end;
procedure TForm1.btn2Click(Sender: TObject);
var
lAppDir:string;
begin
idsrvrhndlrsl1.OnGetPassword:=idsrvrhndlrsl1GetPassword;
lappDir:= extractFilePath(application.exename);
idsrvrhndlrsl1.SSLOptions.KeyFile := lappDir +'key.pem';
idsrvrhndlrsl1.SSLOptions.CertFile := lAppDir+'cert.pem';
idsrvrhndlrsl1.SSLOptions.RootCertFile:= lappDir + 'root.pem';
idsrvrhndlrsl1.SSLOptions.VerifyDirs := lAppDir;
idsrvrhndlrsl1.SSLOptions.Method := sslvSSLv23;
idsrvrhndlrsl1.SSLOptions.Mode := sslmServer;
idhtpsrvr1.Active:=TRUE;
end;
lappDir:= extractFilePath(application.exename)+'cert\';
IdServerIOHandlerSSLOpenSSL1.SSLOptions.KeyFile := lappDir +'key.pem';
IdServerIOHandlerSSLOpenSSL1.SSLOptions.CertFile := lAppDir+'cert.pem';
IdServerIOHandlerSSLOpenSSL1.SSLOptions.RootCertFile:= lappDir +
'root.pem';
IdServerIOHandlerSSLOpenSSL1.SSLOptions.VerifyDirs := lAppDir;
IdServerIOHandlerSSLOpenSSL1.SSLOptions.Method := sslvSSLv23;
IdServerIOHandlerSSLOpenSSL1.SSLOptions.Mode := sslmServer;