cross socket ssl动态库

cross socket ssl动态库

cross socket支持ssl需要动态库的支持,它的源码注释就说得很清楚。

unit Net.OpenSSL;

{
  OpenSSL 下载:
  https://indy.fulgan.com/SSL/
  https://github.com/leenjewel/openssl_for_ios_and_android

  OpenSSL iOS静态库下载:
  https://indy.fulgan.com/SSL/OpenSSLStaticLibs.7z

  LibreSSL 下载:
  http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/

  Linux下需要安装libssl开发包
  sudo apt-get install libssl-dev
}

// 使用 LibreSSL
// LibreSSL 是 OpenSSL 的一个分支, 由 OpenBSD 维护, 接口与 OpenSSL 兼容
// 目前(2.4.2) 执行效率比 OpenSSL(1.0.2h) 低
{.$DEFINE __LIBRE_SSL__}

// iOS真机必须用openssl的静态库
{$IF defined(IOS) and defined(CPUARM)}
  {$DEFINE __SSL_STATIC__}
{$ENDIF}

interface

uses
  {$IFDEF MSWINDOWS}
  Winapi.Windows,
  {$ENDIF}
  {$IFDEF POSIX}
  Posix.Base, Posix.Pthread,
  {$ENDIF}
  System.SysUtils, System.SyncObjs;

const
  SSLEAY_DLL =
    {$IFDEF MSWINDOWS}
      {$IFDEF __LIBRE_SSL__}
        'libssl-39.dll'
      {$ELSE}
        'ssleay32.dll'
      {$ENDIF}
    {$ENDIF}
    {$IFDEF POSIX}
      {$IFDEF __SSL_STATIC__}
        'libssl.a'
      {$ELSEIF defined(MACOS)}
        'libssl.dylib'
      {$ELSE}
        'libssl.so'
      {$ENDIF}
    {$ENDIF};

  LIBEAY_DLL =
    {$IFDEF MSWINDOWS}
      {$IFDEF __LIBRE_SSL__}
        'libcrypto-38.dll'
      {$ELSE}
        'libeay32.dll'
      {$ENDIF}
    {$ENDIF}
    {$IFDEF POSIX}
      {$IFDEF __SSL_STATIC__}
        'libcrypto.a'
      {$ELSEIF defined(MACOS)}
        'libcrypto.dylib'
      {$ELSE}
        'libcrypto.so'
      {$ENDIF}
    {$ENDIF};

  

posted @ 2022-11-01 08:32  delphi中间件  阅读(240)  评论(0编辑  收藏  举报