ssl_sbb.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. {==============================================================================|
  2. | Project : Ararat Synapse | 001.000.003 |
  3. |==============================================================================|
  4. | Content: SSL support for SecureBlackBox |
  5. |==============================================================================|
  6. | Copyright (c)1999-2005, Lukas Gebauer |
  7. | All rights reserved. |
  8. | |
  9. | Redistribution and use in source and binary forms, with or without |
  10. | modification, are permitted provided that the following conditions are met: |
  11. | |
  12. | Redistributions of source code must retain the above copyright notice, this |
  13. | list of conditions and the following disclaimer. |
  14. | |
  15. | Redistributions in binary form must reproduce the above copyright notice, |
  16. | this list of conditions and the following disclaimer in the documentation |
  17. | and/or other materials provided with the distribution. |
  18. | |
  19. | Neither the name of Lukas Gebauer nor the names of its contributors may |
  20. | be used to endorse or promote products derived from this software without |
  21. | specific prior written permission. |
  22. | |
  23. | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
  24. | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
  25. | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
  26. | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
  27. | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
  28. | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
  29. | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
  30. | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  31. | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
  32. | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
  33. | DAMAGE. |
  34. |==============================================================================|
  35. | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
  36. | Portions created by Lukas Gebauer are Copyright (c)2005. |
  37. | All Rights Reserved. |
  38. |==============================================================================|
  39. | Contributor(s): |
  40. | Allen Drennan (adrennan@wiredred.com) |
  41. |==============================================================================|
  42. | History: see HISTORY.HTM from distribution package |
  43. | (Found at URL: http://www.ararat.cz/synapse/) |
  44. |==============================================================================}
  45. {:@abstract(SSL plugin for Eldos SecureBlackBox)
  46. For handling keys and certificates you can use this properties:
  47. @link(TCustomSSL.CertCAFile), @link(TCustomSSL.CertCA),
  48. @link(TCustomSSL.TrustCertificateFile), @link(TCustomSSL.TrustCertificate),
  49. @link(TCustomSSL.PrivateKeyFile), @link(TCustomSSL.PrivateKey),
  50. @link(TCustomSSL.CertificateFile), @link(TCustomSSL.Certificate),
  51. @link(TCustomSSL.PFXFile). For usage of this properties and for possible formats
  52. of keys and certificates refer to SecureBlackBox documentation.
  53. }
  54. {$IFDEF FPC}
  55. {$MODE DELPHI}
  56. {$ENDIF}
  57. {$H+}
  58. unit ssl_sbb;
  59. interface
  60. uses
  61. SysUtils, Classes, Windows, blcksock, synsock, synautil, synacode,
  62. SBClient, SBServer, SBX509, SBWinCertStorage, SBCustomCertStorage,
  63. SBUtils, SBConstants, SBSessionPool;
  64. const
  65. DEFAULT_RECV_BUFFER=32768;
  66. type
  67. {:@abstract(class implementing SecureBlackbox SSL plugin.)
  68. Instance of this class will be created for each @link(TTCPBlockSocket).
  69. You not need to create instance of this class, all is done by Synapse itself!}
  70. TSSLSBB=class(TCustomSSL)
  71. protected
  72. FServer: Boolean;
  73. FElSecureClient:TElSecureClient;
  74. FElSecureServer:TElSecureServer;
  75. FElCertStorage:TElMemoryCertStorage;
  76. FElX509Certificate:TElX509Certificate;
  77. FElX509CACertificate:TElX509Certificate;
  78. FCipherSuites:TBits;
  79. private
  80. FRecvBuffer:String;
  81. FRecvBuffers:String;
  82. FRecvBuffersLock:TRTLCriticalSection;
  83. FRecvDecodedBuffers:String;
  84. function GetCipherSuite:Integer;
  85. procedure Reset;
  86. function Prepare(Server:Boolean):Boolean;
  87. procedure OnError(Sender:TObject; ErrorCode:Integer; Fatal:Boolean; Remote:Boolean);
  88. procedure OnSend(Sender:TObject;Buffer:Pointer;Size:LongInt);
  89. procedure OnReceive(Sender:TObject;Buffer:Pointer;MaxSize:LongInt;var Written:LongInt);
  90. procedure OnData(Sender:TObject;Buffer:Pointer;Size:LongInt);
  91. public
  92. constructor Create(const Value: TTCPBlockSocket); override;
  93. destructor Destroy; override;
  94. {:See @inherited}
  95. function LibVersion: String; override;
  96. {:See @inherited}
  97. function LibName: String; override;
  98. {:See @inherited and @link(ssl_sbb) for more details.}
  99. function Connect: boolean; override;
  100. {:See @inherited and @link(ssl_sbb) for more details.}
  101. function Accept: boolean; override;
  102. {:See @inherited}
  103. function Shutdown: boolean; override;
  104. {:See @inherited}
  105. function BiShutdown: boolean; override;
  106. {:See @inherited}
  107. function SendBuffer(Buffer: TMemory; Len: Integer): Integer; override;
  108. {:See @inherited}
  109. function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override;
  110. {:See @inherited}
  111. function WaitingData: Integer; override;
  112. {:See @inherited}
  113. function GetSSLVersion: string; override;
  114. {:See @inherited}
  115. function GetPeerSubject: string; override;
  116. {:See @inherited}
  117. function GetPeerIssuer: string; override;
  118. {:See @inherited}
  119. function GetPeerName: string; override;
  120. {:See @inherited}
  121. function GetPeerFingerprint: string; override;
  122. {:See @inherited}
  123. function GetCertInfo: string; override;
  124. published
  125. property ElSecureClient:TElSecureClient read FElSecureClient write FElSecureClient;
  126. property ElSecureServer:TElSecureServer read FElSecureServer write FElSecureServer;
  127. property CipherSuites:TBits read FCipherSuites write FCipherSuites;
  128. property CipherSuite:Integer read GetCipherSuite;
  129. end;
  130. implementation
  131. var
  132. FAcceptThread:THandle=0;
  133. // on error
  134. procedure TSSLSBB.OnError(Sender:TObject; ErrorCode:Integer; Fatal:Boolean; Remote:Boolean);
  135. begin
  136. FLastErrorDesc:='';
  137. FLastError:=ErrorCode;
  138. end;
  139. // on send
  140. procedure TSSLSBB.OnSend(Sender:TObject;Buffer:Pointer;Size:LongInt);
  141. var
  142. lResult:Integer;
  143. begin
  144. if FSocket.Socket=INVALID_SOCKET then
  145. Exit;
  146. lResult:=Send(FSocket.Socket,Buffer,Size,0);
  147. if lResult=SOCKET_ERROR then
  148. begin
  149. FLastErrorDesc:='';
  150. FLastError:=WSAGetLastError;
  151. end;
  152. end;
  153. // on receive
  154. procedure TSSLSBB.OnReceive(Sender:TObject;Buffer:Pointer;MaxSize:LongInt;var Written:LongInt);
  155. begin
  156. if GetCurrentThreadId<>FAcceptThread then EnterCriticalSection(FRecvBuffersLock);
  157. try
  158. if Length(FRecvBuffers)<=MaxSize then
  159. begin
  160. Written:=Length(FRecvBuffers);
  161. Move(FRecvBuffers[1],Buffer^,Written);
  162. FRecvBuffers:='';
  163. end
  164. else
  165. begin
  166. Written:=MaxSize;
  167. Move(FRecvBuffers[1],Buffer^,Written);
  168. Delete(FRecvBuffers,1,Written);
  169. end;
  170. finally
  171. if GetCurrentThreadId<>FAcceptThread then LeaveCriticalSection(FRecvBuffersLock);
  172. end;
  173. end;
  174. // on data
  175. procedure TSSLSBB.OnData(Sender:TObject;Buffer:Pointer;Size:LongInt);
  176. var
  177. lString:String;
  178. begin
  179. SetLength(lString,Size);
  180. Move(Buffer^,lString[1],Size);
  181. FRecvDecodedBuffers:=FRecvDecodedBuffers+lString;
  182. end;
  183. { inherited }
  184. constructor TSSLSBB.Create(const Value: TTCPBlockSocket);
  185. var
  186. loop1:Integer;
  187. begin
  188. inherited Create(Value);
  189. FServer:=FALSE;
  190. FElSecureClient:=NIL;
  191. FElSecureServer:=NIL;
  192. FElCertStorage:=NIL;
  193. FElX509Certificate:=NIL;
  194. FElX509CACertificate:=NIL;
  195. SetLength(FRecvBuffer,DEFAULT_RECV_BUFFER);
  196. FRecvBuffers:='';
  197. InitializeCriticalSection(FRecvBuffersLock);
  198. FRecvDecodedBuffers:='';
  199. FCipherSuites:=TBits.Create;
  200. if FCipherSuites<>NIL then
  201. begin
  202. FCipherSuites.Size:=SB_SUITE_LAST+1;
  203. for loop1:=SB_SUITE_FIRST to SB_SUITE_LAST do
  204. FCipherSuites[loop1]:=TRUE;
  205. end;
  206. end;
  207. destructor TSSLSBB.Destroy;
  208. begin
  209. Reset;
  210. inherited Destroy;
  211. if FCipherSuites<>NIL then
  212. FreeAndNIL(FCipherSuites);
  213. DeleteCriticalSection(FRecvBuffersLock);
  214. end;
  215. function TSSLSBB.LibVersion: String;
  216. begin
  217. Result:='SecureBlackBox';
  218. end;
  219. function TSSLSBB.LibName: String;
  220. begin
  221. Result:='ssl_sbb';
  222. end;
  223. function FileToString(lFile:String):String;
  224. var
  225. lStream:TMemoryStream;
  226. begin
  227. Result:='';
  228. lStream:=TMemoryStream.Create;
  229. if lStream<>NIL then
  230. begin
  231. lStream.LoadFromFile(lFile);
  232. if lStream.Size>0 then
  233. begin
  234. lStream.Position:=0;
  235. SetLength(Result,lStream.Size);
  236. Move(lStream.Memory^,Result[1],lStream.Size);
  237. end;
  238. lStream.Free;
  239. end;
  240. end;
  241. function TSSLSBB.GetCipherSuite:Integer;
  242. begin
  243. if FServer then
  244. Result:=FElSecureServer.CipherSuite
  245. else
  246. Result:=FElSecureClient.CipherSuite;
  247. end;
  248. procedure TSSLSBB.Reset;
  249. begin
  250. if FElSecureServer<>NIL then
  251. FreeAndNIL(FElSecureServer);
  252. if FElSecureClient<>NIL then
  253. FreeAndNIL(FElSecureClient);
  254. if FElX509Certificate<>NIL then
  255. FreeAndNIL(FElX509Certificate);
  256. if FElX509CACertificate<>NIL then
  257. FreeAndNIL(FElX509CACertificate);
  258. if FElCertStorage<>NIL then
  259. FreeAndNIL(FElCertStorage);
  260. FSSLEnabled:=FALSE;
  261. end;
  262. function TSSLSBB.Prepare(Server:Boolean): Boolean;
  263. var
  264. loop1:Integer;
  265. lStream:TMemoryStream;
  266. lCertificate,lPrivateKey,lCertCA:String;
  267. begin
  268. Result:=FALSE;
  269. FServer:=Server;
  270. // reset, if necessary
  271. Reset;
  272. // init, certificate
  273. if FCertificateFile<>'' then
  274. lCertificate:=FileToString(FCertificateFile)
  275. else
  276. lCertificate:=FCertificate;
  277. if FPrivateKeyFile<>'' then
  278. lPrivateKey:=FileToString(FPrivateKeyFile)
  279. else
  280. lPrivateKey:=FPrivateKey;
  281. if FCertCAFile<>'' then
  282. lCertCA:=FileToString(FCertCAFile)
  283. else
  284. lCertCA:=FCertCA;
  285. if (lCertificate<>'') and (lPrivateKey<>'') then
  286. begin
  287. FElCertStorage:=TElMemoryCertStorage.Create(NIL);
  288. if FElCertStorage<>NIL then
  289. FElCertStorage.Clear;
  290. // apply ca certificate
  291. if lCertCA<>'' then
  292. begin
  293. FElX509CACertificate:=TElX509Certificate.Create(NIL);
  294. if FElX509CACertificate<>NIL then
  295. begin
  296. with FElX509CACertificate do
  297. begin
  298. lStream:=TMemoryStream.Create;
  299. try
  300. WriteStrToStream(lStream,lCertCA);
  301. lStream.Seek(0,soFromBeginning);
  302. LoadFromStream(lStream);
  303. finally
  304. lStream.Free;
  305. end;
  306. end;
  307. if FElCertStorage<>NIL then
  308. FElCertStorage.Add(FElX509CACertificate);
  309. end;
  310. end;
  311. // apply certificate
  312. FElX509Certificate:=TElX509Certificate.Create(NIL);
  313. if FElX509Certificate<>NIL then
  314. begin
  315. with FElX509Certificate do
  316. begin
  317. lStream:=TMemoryStream.Create;
  318. try
  319. WriteStrToStream(lStream,lCertificate);
  320. lStream.Seek(0,soFromBeginning);
  321. LoadFromStream(lStream);
  322. finally
  323. lStream.Free;
  324. end;
  325. lStream:=TMemoryStream.Create;
  326. try
  327. WriteStrToStream(lStream,lPrivateKey);
  328. lStream.Seek(0,soFromBeginning);
  329. LoadKeyFromStream(lStream);
  330. finally
  331. lStream.Free;
  332. end;
  333. if FElCertStorage<>NIL then
  334. FElCertStorage.Add(FElX509Certificate);
  335. end;
  336. end;
  337. end;
  338. // init, as server
  339. if FServer then
  340. begin
  341. FElSecureServer:=TElSecureServer.Create(NIL);
  342. if FElSecureServer<>NIL then
  343. begin
  344. // init, ciphers
  345. for loop1:=SB_SUITE_FIRST to SB_SUITE_LAST do
  346. FElSecureServer.CipherSuites[loop1]:=FCipherSuites[loop1];
  347. FElSecureServer.Versions:=[sbSSL2,sbSSL3,sbTLS1];
  348. FElSecureServer.ClientAuthentication:=FALSE;
  349. FElSecureServer.OnError:=OnError;
  350. FElSecureServer.OnSend:=OnSend;
  351. FElSecureServer.OnReceive:=OnReceive;
  352. FElSecureServer.OnData:=OnData;
  353. FElSecureServer.CertStorage:=FElCertStorage;
  354. Result:=TRUE;
  355. end;
  356. end
  357. else
  358. // init, as client
  359. begin
  360. FElSecureClient:=TElSecureClient.Create(NIL);
  361. if FElSecureClient<>NIL then
  362. begin
  363. // init, ciphers
  364. for loop1:=SB_SUITE_FIRST to SB_SUITE_LAST do
  365. FElSecureClient.CipherSuites[loop1]:=FCipherSuites[loop1];
  366. FElSecureClient.Versions:=[sbSSL3,sbTLS1];
  367. FElSecureClient.OnError:=OnError;
  368. FElSecureClient.OnSend:=OnSend;
  369. FElSecureClient.OnReceive:=OnReceive;
  370. FElSecureClient.OnData:=OnData;
  371. FElSecureClient.CertStorage:=FElCertStorage;
  372. Result:=TRUE;
  373. end;
  374. end;
  375. end;
  376. function TSSLSBB.Connect:Boolean;
  377. var
  378. lResult:Integer;
  379. begin
  380. Result:=FALSE;
  381. if FSocket.Socket=INVALID_SOCKET then
  382. Exit;
  383. if Prepare(FALSE) then
  384. begin
  385. FElSecureClient.Open;
  386. // reset
  387. FRecvBuffers:='';
  388. FRecvDecodedBuffers:='';
  389. // wait for open or error
  390. while (not FElSecureClient.Active) and
  391. (FLastError=0) do
  392. begin
  393. // data available?
  394. if FRecvBuffers<>'' then
  395. FElSecureClient.DataAvailable
  396. else
  397. begin
  398. // socket recv
  399. lResult:=Recv(FSocket.Socket,@FRecvBuffer[1],Length(FRecvBuffer),0);
  400. if lResult=SOCKET_ERROR then
  401. begin
  402. FLastErrorDesc:='';
  403. FLastError:=WSAGetLastError;
  404. end
  405. else
  406. begin
  407. if lResult>0 then
  408. FRecvBuffers:=FRecvBuffers+Copy(FRecvBuffer,1,lResult)
  409. else
  410. Break;
  411. end;
  412. end;
  413. end;
  414. if FLastError<>0 then
  415. Exit;
  416. FSSLEnabled:=FElSecureClient.Active;
  417. Result:=FSSLEnabled;
  418. end;
  419. end;
  420. function TSSLSBB.Accept:Boolean;
  421. var
  422. lResult:Integer;
  423. begin
  424. Result:=FALSE;
  425. if FSocket.Socket=INVALID_SOCKET then
  426. Exit;
  427. if Prepare(TRUE) then
  428. begin
  429. FAcceptThread:=GetCurrentThreadId;
  430. FElSecureServer.Open;
  431. // reset
  432. FRecvBuffers:='';
  433. FRecvDecodedBuffers:='';
  434. // wait for open or error
  435. while (not FElSecureServer.Active) and
  436. (FLastError=0) do
  437. begin
  438. // data available?
  439. if FRecvBuffers<>'' then
  440. FElSecureServer.DataAvailable
  441. else
  442. begin
  443. // socket recv
  444. lResult:=Recv(FSocket.Socket,@FRecvBuffer[1],Length(FRecvBuffer),0);
  445. if lResult=SOCKET_ERROR then
  446. begin
  447. FLastErrorDesc:='';
  448. FLastError:=WSAGetLastError;
  449. end
  450. else
  451. begin
  452. if lResult>0 then
  453. FRecvBuffers:=FRecvBuffers+Copy(FRecvBuffer,1,lResult)
  454. else
  455. Break;
  456. end;
  457. end;
  458. end;
  459. if FLastError<>0 then
  460. Exit;
  461. FSSLEnabled:=FElSecureServer.Active;
  462. Result:=FSSLEnabled;
  463. end;
  464. end;
  465. function TSSLSBB.Shutdown:Boolean;
  466. begin
  467. Result:=BiShutdown;
  468. end;
  469. function TSSLSBB.BiShutdown: boolean;
  470. begin
  471. Reset;
  472. Result:=TRUE;
  473. end;
  474. function TSSLSBB.SendBuffer(Buffer: TMemory; Len: Integer): Integer;
  475. begin
  476. if FServer then
  477. FElSecureServer.SendData(Buffer,Len)
  478. else
  479. FElSecureClient.SendData(Buffer,Len);
  480. Result:=Len;
  481. end;
  482. function TSSLSBB.RecvBuffer(Buffer: TMemory; Len: Integer): Integer;
  483. begin
  484. Result:=0;
  485. try
  486. // recv waiting, if necessary
  487. if FRecvDecodedBuffers='' then
  488. WaitingData;
  489. // received
  490. if Length(FRecvDecodedBuffers)<Len then
  491. begin
  492. Result:=Length(FRecvDecodedBuffers);
  493. Move(FRecvDecodedBuffers[1],Buffer^,Result);
  494. FRecvDecodedBuffers:='';
  495. end
  496. else
  497. begin
  498. Result:=Len;
  499. Move(FRecvDecodedBuffers[1],Buffer^,Result);
  500. Delete(FRecvDecodedBuffers,1,Result);
  501. end;
  502. except
  503. // ignore
  504. end;
  505. end;
  506. function TSSLSBB.WaitingData: Integer;
  507. var
  508. lResult:Integer;
  509. lRecvBuffers:Boolean;
  510. begin
  511. Result:=0;
  512. if FSocket.Socket=INVALID_SOCKET then
  513. Exit;
  514. // data available?
  515. if GetCurrentThreadId<>FAcceptThread then EnterCriticalSection(FRecvBuffersLock);
  516. try
  517. lRecvBuffers:=FRecvBuffers<>'';
  518. finally
  519. if GetCurrentThreadId<>FAcceptThread then LeaveCriticalSection(FRecvBuffersLock);
  520. end;
  521. if lRecvBuffers then
  522. begin
  523. if FServer then
  524. FElSecureServer.DataAvailable
  525. else
  526. FElSecureClient.DataAvailable;
  527. end
  528. else
  529. begin
  530. // socket recv
  531. lResult:=Recv(FSocket.Socket,@FRecvBuffer[1],Length(FRecvBuffer),0);
  532. if lResult=SOCKET_ERROR then
  533. begin
  534. FLastErrorDesc:='';
  535. FLastError:=WSAGetLastError;
  536. end
  537. else
  538. begin
  539. if GetCurrentThreadId<>FAcceptThread then EnterCriticalSection(FRecvBuffersLock);
  540. try
  541. FRecvBuffers:=FRecvBuffers+Copy(FRecvBuffer,1,lResult);
  542. finally
  543. if GetCurrentThreadId<>FAcceptThread then LeaveCriticalSection(FRecvBuffersLock);
  544. end;
  545. // data available?
  546. if GetCurrentThreadId<>FAcceptThread then EnterCriticalSection(FRecvBuffersLock);
  547. try
  548. lRecvBuffers:=FRecvBuffers<>'';
  549. finally
  550. if GetCurrentThreadId<>FAcceptThread then LeaveCriticalSection(FRecvBuffersLock);
  551. end;
  552. if lRecvBuffers then
  553. begin
  554. if FServer then
  555. FElSecureServer.DataAvailable
  556. else
  557. FElSecureClient.DataAvailable;
  558. end;
  559. end;
  560. end;
  561. // decoded buffers result
  562. Result:=Length(FRecvDecodedBuffers);
  563. end;
  564. function TSSLSBB.GetSSLVersion: string;
  565. begin
  566. Result:='SSLv3 or TLSv1';
  567. end;
  568. function TSSLSBB.GetPeerSubject: string;
  569. begin
  570. Result := '';
  571. // if FServer then
  572. // must return subject of the client certificate
  573. // else
  574. // must return subject of the server certificate
  575. end;
  576. function TSSLSBB.GetPeerName: string;
  577. begin
  578. Result := '';
  579. // if FServer then
  580. // must return commonname of the client certificate
  581. // else
  582. // must return commonname of the server certificate
  583. end;
  584. function TSSLSBB.GetPeerIssuer: string;
  585. begin
  586. Result := '';
  587. // if FServer then
  588. // must return issuer of the client certificate
  589. // else
  590. // must return issuer of the server certificate
  591. end;
  592. function TSSLSBB.GetPeerFingerprint: string;
  593. begin
  594. Result := '';
  595. // if FServer then
  596. // must return a unique hash string of the client certificate
  597. // else
  598. // must return a unique hash string of the server certificate
  599. end;
  600. function TSSLSBB.GetCertInfo: string;
  601. begin
  602. Result := '';
  603. // if FServer then
  604. // must return a text representation of the ASN of the client certificate
  605. // else
  606. // must return a text representation of the ASN of the server certificate
  607. end;
  608. {==============================================================================}
  609. initialization
  610. SSLImplementation := TSSLSBB;
  611. finalization
  612. end.