macos编译openssl

本文档详细介绍了如何在MacOS 10.15.6系统上从源代码编译并安装OpenSSL 1.1.1d版本。首先从官方网站下载源码,然后进行解压和配置,使用'./config'命令指定安装路径。接着执行'make'进行编译,最后通过'sudo make install'完成安装,将静态库、头文件、可执行文件和文档分别安装到相应目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 <https://github.com/openssl/openssl/issues> ***

*** 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$

编译

chenyj-imac:openssl-1.1.1d chenyj$ make
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
        "-oMakefile" crypto/include/internal/bn_conf.h.in > crypto/include/internal/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
        "-oMakefile" crypto/include/internal/dso_conf.h.in > crypto/include/internal/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
        "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
/Applications/Xcode.app/Contents/Developer/usr/bin/make depend && /Applications/Xcode.app/Contents/Developer/usr/bin/make _all
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
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
…….
编译文件过程........

安装

chenyj-imac:openssl-1.1.1d chenyj$ sudo make install
_build_libs
make[1]: Nothing to be done for `_build_libs'.
*** Installing runtime libraries
*** Installing development files
install ./include/openssl/aes.h -> /usr/local/include/openssl/aes.h
install ./include/openssl/asn1.h -> /usr/local/include/openssl/asn1.h
install ./include/openssl/asn1_mac.h -> /usr/local/include/openssl/asn1_mac.h
install ./include/openssl/asn1err.h -> /usr/local/include/openssl/asn1err.h
install ./include/openssl/asn1t.h -> /usr/local/include/openssl/asn1t.h
install ./include/openssl/async.h -> /usr/local/include/openssl/async.h
install ./include/openssl/asyncerr.h -> /usr/local/include/openssl/asyncerr.h
install ./include/openssl/bio.h -> /usr/local/include/openssl/bio.h
…………
安装过程........
/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
/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
/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
/usr/local/share/doc/openssl/html/man5/config.html
/usr/local/share/doc/openssl/html/man5/x509v3_config.html
/usr/local/share/doc/openssl/html/man7/bio.html
/usr/local/share/doc/openssl/html/man7/crypto.html
/usr/local/share/doc/openssl/html/man7/ct.html
/usr/local/share/doc/openssl/html/man7/des_modes.html
/usr/local/share/doc/openssl/html/man7/Ed25519.html
/usr/local/share/doc/openssl/html/man7/Ed448.html -> /usr/local/share/doc/openssl/html/man7/Ed25519.html
/usr/local/share/doc/openssl/html/man7/evp.html
/usr/local/share/doc/openssl/html/man7/ossl_store-file.html
/usr/local/share/doc/openssl/html/man7/ossl_store.html
/usr/local/share/doc/openssl/html/man7/passphrase-encoding.html
/usr/local/share/doc/openssl/html/man7/RAND.html
/usr/local/share/doc/openssl/html/man7/RAND_DRBG.html
/usr/local/share/doc/openssl/html/man7/RSA-PSS.html
/usr/local/share/doc/openssl/html/man7/scrypt.html
/usr/local/share/doc/openssl/html/man7/SM2.html
/usr/local/share/doc/openssl/html/man7/ssl.html
/usr/local/share/doc/openssl/html/man7/X25519.html
/usr/local/share/doc/openssl/html/man7/X448.html -> /usr/local/share/doc/openssl/html/man7/X25519.html
/usr/local/share/doc/openssl/html/man7/x509.html
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值