|
| 1 | +--- |
| 2 | +id: support-fips-in-apisix |
| 3 | +title: 通过 OpenSSL 3.0 使 APISIX 支持 FIPS 模式 |
| 4 | +keywords: |
| 5 | + - API 网关 |
| 6 | + - Apache APISIX |
| 7 | + - 贡献代码 |
| 8 | + - 构建 APISIX |
| 9 | + - OpenSSL 3.0 FIPS |
| 10 | +description: 本文将介绍如何在 Apache APISIX 中使用 OpenSSL 3.0 来编译 apisix-base,即可启用 FIPS 模式。 |
| 11 | +--- |
| 12 | + |
| 13 | +<!-- |
| 14 | +# |
| 15 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 16 | +# contributor license agreements. See the NOTICE file distributed with |
| 17 | +# this work for additional information regarding copyright ownership. |
| 18 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 19 | +# (the "License"); you may not use this file except in compliance with |
| 20 | +# the License. You may obtain a copy of the License at |
| 21 | +# |
| 22 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 23 | +# |
| 24 | +# Unless required by applicable law or agreed to in writing, software |
| 25 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 26 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 27 | +# See the License for the specific language governing permissions and |
| 28 | +# limitations under the License. |
| 29 | +# |
| 30 | +--> |
| 31 | + |
| 32 | +目前,OpenSSL 3.0 [支持了](https://www.openssl.org/blog/blog/2022/08/24/FIPS-validation-certificate-issued/) [FIPS](https://en.wikipedia.org/wiki/FIPS_140-2) 模式。为了在 APISIX 中支持 FIPS 模式,你应该使用 OpenSSL 3.0 来编译 apisix-base。 |
| 33 | + |
| 34 | +## 编译 |
| 35 | + |
| 36 | +如果你需要使用 OpenSSL 3.0 来编译 apisix-base,请以 root 用户角色来执行以下命令: |
| 37 | + |
| 38 | +```bash |
| 39 | +cd $(mktemp -d) |
| 40 | +OPENSSL3_PREFIX=${OPENSSL3_PREFIX-/usr/local} |
| 41 | +apt install -y build-essential |
| 42 | +git clone https://github.com/openssl/openssl |
| 43 | +cd openssl |
| 44 | +./Configure --prefix=$OPENSSL3_PREFIX/openssl-3.0 enable-fips |
| 45 | +make install |
| 46 | +echo $OPENSSL3_PREFIX/openssl-3.0/lib64 > /etc/ld.so.conf.d/openssl3.conf |
| 47 | +ldconfig |
| 48 | +$OPENSSL3_PREFIX/openssl-3.0/bin/openssl fipsinstall -out $OPENSSL3_PREFIX/openssl-3.0/ssl/fipsmodule.cnf -module $OPENSSL3_PREFIX/openssl-3.0/lib64/ossl-modules/fips.so |
| 49 | +sed -i 's@# .include [email protected] '"$OPENSSL3_PREFIX"'/openssl-3.0/ssl/fipsmodule.cnf@g; s/# \(fips = fips_sect\)/\1\nbase = base_sect\n\n[base_sect]\nactivate=1\n/g' $OPENSSL3_PREFIX/openssl-3.0/ssl/openssl.cnf |
| 50 | +cd .. |
| 51 | + |
| 52 | +export cc_opt="-I$OPENSSL3_PREFIX/openssl-3.0/include" |
| 53 | +export ld_opt="-L$OPENSSL3_PREFIX/openssl-3.0/lib64 -Wl,-rpath,$OPENSSL3_PREFIX/openssl-3.0/lib64" |
| 54 | + |
| 55 | +wget https://raw.githubusercontent.com/api7/apisix-build-tools/master/build-apisix-base.sh |
| 56 | +chmod +x build-apisix-base.sh |
| 57 | +./build-apisix-base.sh latest |
| 58 | +``` |
| 59 | + |
| 60 | +apisix-base 将安装在 `/usr/local/openresty-debug`。 |
0 commit comments