Skip to content

Commit 5decdba

Browse files
fix: Support self-signed SSL certs in macOS keychain (x86_64)
1 parent 743078b commit 5decdba

File tree

5 files changed

+91
-6
lines changed

5 files changed

+91
-6
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,34 @@ jobs:
7272
- name: Add Rustup Target
7373
run: rustup target add ${{ matrix.target }}
7474

75+
# On x86_64, this environment variable specifies to the openssl-sys crate
76+
# where to find the OpenSSL library.
77+
- name: Set OpenSSL env (x86_64)
78+
if: matrix.arch == 'x86_64'
79+
run: echo "X86_64_APPLE_DARWIN_OPENSSL_DIR=${{ github.workspace }}/openssl-x86_64" >> $GITHUB_ENV
80+
81+
- name: Get OpenSSL cache month (x86_64)
82+
if: matrix.arch == 'x86_64'
83+
id: cache-date
84+
run: echo "month=$(date +%Y-%m)" >> $GITHUB_OUTPUT
85+
86+
- name: Cache x86_64 OpenSSL
87+
if: matrix.arch == 'x86_64'
88+
id: cache-openssl-x86
89+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # 5.0.1
90+
with:
91+
path: ${{ env.X86_64_APPLE_DARWIN_OPENSSL_DIR }}
92+
key: openssl-x86_64-${{ runner.os }}-${{ steps.cache-date.outputs.month }}
93+
94+
# To cross-compile for x86_64 from an ARM-based macOS runner, we need to have the
95+
# x86_64 OpenSSL libraries installed locally.
96+
- name: Download x86_64 OpenSSL
97+
if: matrix.arch == 'x86_64' && steps.cache-openssl-x86.outputs.cache-hit != 'true'
98+
run: |
99+
brew fetch --bottle-tag=sonoma openssl@3
100+
mkdir -p $X86_64_APPLE_DARWIN_OPENSSL_DIR
101+
tar xzf $(brew --cache --bottle-tag=sonoma openssl@3) -C $X86_64_APPLE_DARWIN_OPENSSL_DIR --strip-components=2
102+
75103
- name: Cache Dependencies
76104
uses: swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # 2.8.2
77105

.github/workflows/lint.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636

3737
name: ${{ matrix.display-os }}
3838
runs-on: ${{ matrix.os }}
39+
3940
steps:
4041
- name: Checkout Repository
4142
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
@@ -52,6 +53,34 @@ jobs:
5253
sudo apt-get update
5354
sudo apt-get install -y musl-tools
5455
56+
# On x86_64, this environment variable specifies to the openssl-sys crate
57+
# where to find the OpenSSL library.
58+
- name: Set OpenSSL env (x86_64)
59+
if: matrix.target == 'x86_64-apple-darwin'
60+
run: echo "X86_64_APPLE_DARWIN_OPENSSL_DIR=${{ github.workspace }}/openssl-x86_64" >> $GITHUB_ENV
61+
62+
- name: Get OpenSSL cache month (x86_64)
63+
if: matrix.target == 'x86_64-apple-darwin'
64+
id: cache-date
65+
run: echo "month=$(date +%Y-%m)" >> $GITHUB_OUTPUT
66+
67+
- name: Cache x86_64 OpenSSL
68+
if: matrix.target == 'x86_64-apple-darwin'
69+
id: cache-openssl-x86
70+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # 5.0.1
71+
with:
72+
path: ${{ env.X86_64_APPLE_DARWIN_OPENSSL_DIR }}
73+
key: openssl-x86_64-${{ runner.os }}-${{ steps.cache-date.outputs.month }}
74+
75+
# To cross-compile for x86_64 from an ARM-based macOS runner, we need to have the
76+
# x86_64 OpenSSL libraries installed locally.
77+
- name: Download x86_64 OpenSSL
78+
if: matrix.target == 'x86_64-apple-darwin' && steps.cache-openssl-x86.outputs.cache-hit != 'true'
79+
run: |
80+
brew fetch --bottle-tag=sonoma openssl@3
81+
mkdir -p $X86_64_APPLE_DARWIN_OPENSSL_DIR
82+
tar xzf $(brew --cache --bottle-tag=sonoma openssl@3) -C $X86_64_APPLE_DARWIN_OPENSSL_DIR --strip-components=2
83+
5584
- name: Cache Dependencies
5685
uses: swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # 2.8.2
5786

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,34 @@ jobs:
5252
sudo apt-get update
5353
sudo apt-get install -y musl-tools
5454
55+
# On x86_64, this environment variable specifies to the openssl-sys crate
56+
# where to find the OpenSSL library.
57+
- name: Set OpenSSL env (x86_64)
58+
if: matrix.target == 'x86_64-apple-darwin'
59+
run: echo "X86_64_APPLE_DARWIN_OPENSSL_DIR=${{ github.workspace }}/openssl-x86_64" >> $GITHUB_ENV
60+
61+
- name: Get OpenSSL cache month (x86_64)
62+
if: matrix.target == 'x86_64-apple-darwin'
63+
id: cache-date
64+
run: echo "month=$(date +%Y-%m)" >> $GITHUB_OUTPUT
65+
66+
- name: Cache x86_64 OpenSSL
67+
if: matrix.target == 'x86_64-apple-darwin'
68+
id: cache-openssl-x86
69+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # 5.0.1
70+
with:
71+
path: ${{ env.X86_64_APPLE_DARWIN_OPENSSL_DIR }}
72+
key: openssl-x86_64-${{ runner.os }}-${{ steps.cache-date.outputs.month }}
73+
74+
# To cross-compile for x86_64 from an ARM-based macOS runner, we need to have the
75+
# x86_64 OpenSSL libraries installed locally.
76+
- name: Download x86_64 OpenSSL
77+
if: matrix.target == 'x86_64-apple-darwin' && steps.cache-openssl-x86.outputs.cache-hit != 'true'
78+
run: |
79+
brew fetch --bottle-tag=sonoma openssl@3
80+
mkdir -p $X86_64_APPLE_DARWIN_OPENSSL_DIR
81+
tar xzf $(brew --cache --bottle-tag=sonoma openssl@3) -C $X86_64_APPLE_DARWIN_OPENSSL_DIR --strip-components=2
82+
5583
- name: Cache Dependencies
5684
uses: swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # 2.8.2
5785

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ clap = { version = "4.1.6", default-features = false, features = [
2424
] }
2525
clap_complete = "4.4.3"
2626
console = "0.15.5"
27-
curl = { version = "0.4.46" }
27+
curl = "0.4.46"
2828
dirs = "4.0.0"
2929
dotenvy = "0.15.7"
3030
elementtree = "1.2.3"
@@ -127,10 +127,10 @@ openssl-probe = "0.1.5"
127127
[target."cfg(windows)".dependencies]
128128
windows-sys = { version = "0.59.0", features = ["Win32_Storage_FileSystem"] }
129129

130-
# Use static curl/SSL on all platforms except ARM-based macOS.
131-
# We link dynamically on ARM macOS; that way we can support self-signed certificates
130+
# Use static curl/SSL on non-macOS platforms
131+
# We link dynamically on macOS; that way we can support self-signed certificates
132132
# trusted in the macOS keychain.
133-
[target."cfg(not(all(target_os = \"macos\", target_arch = \"aarch64\")))".dependencies]
133+
[target."cfg(not(target_os = \"macos\"))".dependencies]
134134
curl = { version = "0.4.46", features = ["static-curl", "static-ssl"] }
135135

136136
# We optimize the release build for size.

0 commit comments

Comments
 (0)