• macos编译openssl


    openssl是加解密经常用到的的一个开源库,很多项目中有用到,比如账号登录,数据库加密,libcurl访问https等,一般我们用到的是在window平台,而且很多都可以在网上找到现成的库,在macos系统用到的比较少,可能是开发少的原因。本篇介绍在macos中编译openssl.

    macos系统版本10.15.6

    1.到官网下载openssl源码

    /source/old/1.1.1/index.html

    这里下载的是openssl-1.1.1d 的版本

    解压

    chenyj-imac:openssl-1.1.1d chenyj$  tar -zxf openssl-1.1.1d.tar.gz 

    切换到openssl-1.1.1d目录

    编译配置

    chenyj-imac:openssl-1.1.1d chenyj$ ./config -fPIC no-shared --prefix=/usr/local

    Operating system: x86_64-apple-darwinDarwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64

    Configuring OpenSSL version 1.1.1d (0x1010104fL) for darwin64-x86_64-cc

    Using os-specific seed configuration

    Creating configdata.pm

    Creating Makefile

    **********************************************************************

    *** ***

    *** OpenSSL has been successfully configured ***

    *** ***

    *** If you encounter a problem while building, please open an ***

    *** issue on GitHub ***

    *** and include the output from the following command: ***

    *** ***

    *** perl configdata.pm --dump ***

    *** ***

    *** (If you are new to OpenSSL, you might want to consult the ***

    *** 'Troubleshooting' section in the INSTALL file first) ***

    *** ***

    **********************************************************************

    WARNING! If you wish to build 32-bit libraries, then you have to

    invoke 'KERNEL_BITS=32 ./config '-fPIC' 'no-shared' '--prefix=/usr/local''.

    chenyj-imac:openssl-1.1.1d chenyj$

    编译

    1. chenyj-imac:openssl-1.1.1d chenyj$ make
    2. /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    3. "-oMakefile" crypto/include/internal/bn_conf.h.in > crypto/include/internal/bn_conf.h
    4. /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    5. "-oMakefile" crypto/include/internal/dso_conf.h.in > crypto/include/internal/dso_conf.h
    6. /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    7. "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
    8. /Applications/Xcode.app/Contents/Developer/usr/bin/make depend && /Applications/Xcode.app/Contents/Developer/usr/bin/make _all
    9. cc -I. -Iinclude -fPIC -arch x86_64 -O3 -Wall -fPIC -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
    10. cc -I. -Iinclude -fPIC -arch x86_64 -O3 -Wall -fPIC -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG -MMD -MF apps/apps.d.tmp -MT apps/apps.o -c -o apps/apps.o apps/apps.c
    11. …….
    12. 编译文件过程........

    安装

    1. chenyj-imac:openssl-1.1.1d chenyj$ sudo make install
    2. _build_libs
    3. make[1]: Nothing to be done for `_build_libs'.
    4. *** Installing runtime libraries
    5. *** Installing development files
    6. install ./include/openssl/aes.h -> /usr/local/include/openssl/aes.h
    7. install ./include/openssl/asn1.h -> /usr/local/include/openssl/asn1.h
    8. install ./include/openssl/asn1_mac.h -> /usr/local/include/openssl/asn1_mac.h
    9. install ./include/openssl/asn1err.h -> /usr/local/include/openssl/asn1err.h
    10. install ./include/openssl/asn1t.h -> /usr/local/include/openssl/asn1t.h
    11. install ./include/openssl/async.h -> /usr/local/include/openssl/async.h
    12. install ./include/openssl/asyncerr.h -> /usr/local/include/openssl/asyncerr.h
    13. install ./include/openssl/bio.h -> /usr/local/include/openssl/bio.h
    14. …………
    15. 安装过程........
    16. /usr/local/share/doc/openssl/html/man3/X509_REVOKED_get_ext_by_critical.html -> /usr/local/share/doc/openssl/html/man3/X509v3_get_ext_by_NID.html
    17. /usr/local/share/doc/openssl/html/man3/X509_REVOKED_delete_ext.html -> /usr/local/share/doc/openssl/html/man3/X509v3_get_ext_by_NID.html
    18. /usr/local/share/doc/openssl/html/man3/X509_REVOKED_add_ext.html -> /usr/local/share/doc/openssl/html/man3/X509v3_get_ext_by_NID.html
    19. /usr/local/share/doc/openssl/html/man5/config.html
    20. /usr/local/share/doc/openssl/html/man5/x509v3_config.html
    21. /usr/local/share/doc/openssl/html/man7/bio.html
    22. /usr/local/share/doc/openssl/html/man7/crypto.html
    23. /usr/local/share/doc/openssl/html/man7/ct.html
    24. /usr/local/share/doc/openssl/html/man7/des_modes.html
    25. /usr/local/share/doc/openssl/html/man7/Ed25519.html
    26. /usr/local/share/doc/openssl/html/man7/Ed448.html -> /usr/local/share/doc/openssl/html/man7/Ed25519.html
    27. /usr/local/share/doc/openssl/html/man7/evp.html
    28. /usr/local/share/doc/openssl/html/man7/ossl_store-file.html
    29. /usr/local/share/doc/openssl/html/man7/ossl_store.html
    30. /usr/local/share/doc/openssl/html/man7/passphrase-encoding.html
    31. /usr/local/share/doc/openssl/html/man7/RAND.html
    32. /usr/local/share/doc/openssl/html/man7/RAND_DRBG.html
    33. /usr/local/share/doc/openssl/html/man7/RSA-PSS.html
    34. /usr/local/share/doc/openssl/html/man7/scrypt.html
    35. /usr/local/share/doc/openssl/html/man7/SM2.html
    36. /usr/local/share/doc/openssl/html/man7/ssl.html
    37. /usr/local/share/doc/openssl/html/man7/X25519.html
    38. /usr/local/share/doc/openssl/html/man7/X448.html -> /usr/local/share/doc/openssl/html/man7/X25519.html
    39. /usr/local/share/doc/openssl/html/man7/x509.html
    40. chenyj-imac:openssl-1.1.1d chenyj$

    编译安装完成后,

    静态库安装在/usr/local/lib目录下

    libssl.a  libcrypto.a

    头文件安装在/usr/local/include目录下

    /usr/local/include/openssl

    可执行文件安装在/usr/local/bin目录下

    openssl     c_rehash

    文档安装在/usr/local/share/doc目录下

    openssl/html      /usr/local/share/man

    配置文件安装在/usr/local/share/pkgconfig目录下

    libcrypto.pc    openssl.pc  libssl.pc

    参考:

    libcurl支持https_CAir2的博客-CSDN博客_libcurl支持https

    https://www.jianshu.com/p/5e46df9c5fe7

  • 相关阅读:
    Python 中的滚动赫斯特指数-可视化市场节奏
    gulimall基础篇回顾Day-08
    Qt5开发从入门到精通——第六篇二节( 图像与图片——基础图形的绘制 )
    【kali-权限提升】(4.2.2)社会工程学工具包:web站点克隆钓鱼
    基于TRE文章的非线性模型化线性方法
    【英语:基础进阶_核心词汇扩充】E1.常见词前缀拓词
    Transformer8
    网络设置有效性检测之C#设计笔记(十七)
    CSS的基础
    Spring IOC 常用注解与使用
  • 原文地址:https://blog.csdn.net/chenyijun/article/details/126721017