【发布时间】:2021-02-04 13:22:59
【问题描述】:
我有一个非常简单的TIdTCPServer 来测试没有证书的 OpenSSL。 libeay32.dll 和 ssleay32.dll OpenSSL 文件与项目位于同一文件夹中。我使用 Delphi 10.3 和 OpenSSL 1.0.2o。
然后我通过运行openssl s_client -connect localhost:443 来测试与它的连接。
这会在以下服务器端产生异常:
Project Project19.exe raised exception class EIdOSSLUnderlyingCryptoError with message 'Error accepting connection with SSL.
error:1408A0C1:SSL routines:ssl3_get_client_hello:no shared cipher'.
以及 s_client 端的错误:
openssl s_client -connect localhost:443
WARNING: can''t open config file: /usr/local/ssl/openssl.cnf
CONNECTED(00000180)
18424:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:.\ssl\s23_clnt.c:802:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 307 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1612443994
Timeout : 300 (sec)
Verify return code: 0 (ok)
---
即使我创建简单的 TIdTCPClient 来测试它也会产生相同的握手失败。
unit Unit19;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdSocketHandle, IdContext, IdTCPConnection, IdTCPClient,
IdBaseComponent, IdComponent, IdCustomTCPServer, IdTCPServer, IdSSLOpenSSL,IdSSL,
IdSSLOpenSSLHeaders, IdServerIOHandler, IdExplicitTLSClientServerBase, IdFTP;
type
TForm18 = class(TForm)
ButtonActivateServer: TButton;
TCPServer: TIdTCPServer;
procedure ButtonActivateServerClick(Sender: TObject);
procedure TCPServerExecute(AContext: TIdContext);
procedure TCPServerConnect(AContext: TIdContext);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form18: TForm18;
implementation
{$R *.dfm}
procedure TForm18.ButtonActivateServerClick(Sender: TObject);
var
LSSLIOHandler : TIdServerIOHandlerSSLOpenSSL;
Binding : TIdSocketHandle;
begin
TCPServer.Bindings.Clear;
TCPServer.DefaultPort := 443;
Binding := TCPServer.Bindings.Add;
Binding.IP := '0.0.0.0';
LSSLIOHandler := TIdServerIOHandlerSSLOpenSSL.Create(TCPServer);
LSSLIOHandler.SSLOptions.Mode := sslmServer;
LSSLIOHandler.SSLOptions.VerifyMode := [];
LSSLIOHandler.SSLOptions.VerifyDepth := 0;
LSSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1..sslvTLSv1_2];
TCPServer.IOHandler := LSSLIOHandler;
TCPServer.Active := True;
end;
procedure TForm18.TCPServerConnect(AContext: TIdContext);
begin
If AContext.Connection.IOHandler is TIdSSLIOHandlerSocketBase then
TIdSSLIOHandlerSocketBase(AContext.Connection.IOHandler).PassThrough := False;
end;
procedure TForm18.TCPServerExecute(AContext: TIdContext);
var
S : String;
begin
S := AContext.Connection.IOHandler.AllData;
end;
end.
关于我做错了什么有什么想法吗?我是否需要指定一个 CipherList 或更具体的?证书是必须的吗?
【问题讨论】:
-
您也可以尝试使用
nmap --script ssl-enum-ciphers -p 443 localhost显示服务器上所有兼容的密码。