Skip to content

Commit 28c3cc8

Browse files
authored
Update openssl version (Azure#2437)
* Update openssl version Fixes GHSA-4fcv-w3qc-ppgg * Add vcpkg.json * Integrate vcpkg to get OpenSSL on Windows * Use openssl in a test It's the only way to be sure. * Update CONTRIBUTING.md instructions
1 parent 36682f3 commit 28c3cc8

File tree

13 files changed

+127
-18
lines changed

13 files changed

+127
-18
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Cargo.lock
1212
.assets/
1313
.proxy/
1414
tests/data/
15+
review/
16+
17+
# Dependencies.
18+
vcpkg_installed/
1519

1620
# Editor user customizations.
1721
.vscode/launch.json
@@ -27,5 +31,3 @@ tests/data/
2731

2832
# Temporary folder to refresh SDK with TypeSpec.
2933
TempTypeSpecFiles/
30-
31-
review/

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Since `openssl-sys` supports [vcpkg](https://learn.microsoft.com/vcpkg/), you ca
5555
2. Run the bootstrap script to download a prebuilt binary:
5656

5757
```pwsh
58-
cd vcpkg; .\bootstrap-vcpkg.bat
58+
cd vcpkg
59+
.\bootstrap-vcpkg.bat
5960
```
6061

6162
3. Set up environment variables:
@@ -67,10 +68,13 @@ Since `openssl-sys` supports [vcpkg](https://learn.microsoft.com/vcpkg/), you ca
6768

6869
To persist these variables for future sessions, remember to set them in the Windows System Environment Variables panel.
6970

70-
4. In the root of this repo, run:
71+
4. Change directories into the `eng/` folder in this repo and run:
7172

7273
```pwsh
74+
cd eng
7375
vcpkg install
76+
77+
$env:OPENSSL_DIR = "$PWD\vcpkg_installed\x64-windows"
7478
```
7579

7680
### Linting

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ hmac = { version = "0.12" }
9393
litemap = "0.7.4"
9494
log = "0.4"
9595
oauth2 = { version = "5.0.0", default-features = false }
96-
openssl = { version = "0.10.70" }
96+
openssl = { version = "0.10.72" }
9797
pin-project = "1.0"
9898
proc-macro2 = "1.0.86"
9999
quick-xml = { version = "0.31", features = ["serialize", "serde-types"] }

eng/pipelines/templates/jobs/ci.tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
parameters:
5050
Toolchain: $(RustToolchainName)
5151

52+
- template: /eng/pipelines/templates/steps/vcpkg.yml
53+
5254
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml@self
5355

5456
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml@self

eng/pipelines/templates/jobs/live.tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ jobs:
6666
parameters:
6767
Toolchain: $(RustToolchainName)
6868

69+
- template: /eng/pipelines/templates/steps/vcpkg.yml
70+
6971
- ${{ parameters.PreSteps }}
7072

7173
- template: /eng/common/TestResources/build-test-resource-config.yml
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
steps:
2+
- pwsh: |
3+
Write-Host '##vso[task.setvariable variable=VCPKG_BINARY_SOURCES_SECRET;issecret=true;]clear;x-azblob,https://azuresdkartifacts.blob.core.windows.net/public-vcpkg-container,,read'
4+
Write-Host '##vso[task.setvariable variable=X_VCPKG_ASSET_SOURCES_SECRET;issecret=true;]clear;x-azurl,https://azuresdkartifacts.blob.core.windows.net/public-vcpkg-container,,read'
5+
displayName: Set vcpkg variables
6+
7+
- script: vcpkg --version
8+
condition: >-
9+
and(
10+
succeeded(),
11+
eq(variables['Agent.OS'], 'Windows_NT')
12+
)
13+
displayName: vcpkg --version
14+
15+
- ${{if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}:
16+
- task: AzurePowerShell@5
17+
displayName: Set vcpkg write-mode cache
18+
inputs:
19+
ScriptType: FilePath
20+
ScriptPath: eng/scripts/Set-VcpkgWriteModeCache.ps1
21+
azureSubscription: Azure SDK Artifacts
22+
azurePowerShellVersion: LatestVersion
23+
pwsh: true
24+
# This step is idempotent and can be run multiple times in cases of
25+
# failure and partial execution.
26+
retryCountOnTaskFailure: 3
27+
28+
- pwsh: |
29+
vcpkg install
30+
Write-Host "##vso[task.setvariable variable=VCPKG_ROOT;]${env:VCPKG_INSTALLATION_ROOT}"
31+
Write-Host "##vso[task.setvariable variable=VCPKG_INSTALLED_ROOT;]$PWD\vcpkg_installed"
32+
Write-Host "##vso[task.setvariable variable=OPENSSL_DIR;]$PWD\vcpkg_installed\x64-windows"
33+
condition: >-
34+
and(
35+
succeeded(),
36+
eq(variables['Agent.OS'], 'Windows_NT')
37+
)
38+
displayName: vcpkg install
39+
workingDirectory: eng/
40+
env:
41+
VCPKG_BINARY_SOURCES: $(VCPKG_BINARY_SOURCES_SECRET)
42+
X_VCPKG_ASSET_SOURCES: $(X_VCPKG_ASSET_SOURCES_SECRET)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/env pwsh
2+
param(
3+
[string] $StorageAccountName = 'azuresdkartifacts',
4+
[string] $StorageContainerName = 'public-vcpkg-container'
5+
)
6+
7+
. "$PSScriptRoot/../common/scripts/Helpers/PSModule-Helpers.ps1"
8+
9+
Write-Host "`$env:PSModulePath = $($env:PSModulePath)"
10+
11+
# Work around double backslash
12+
if ($IsWindows) {
13+
$hostedAgentModulePath = $env:SystemDrive + "\\Modules"
14+
$moduleSeperator = ";"
15+
}
16+
else {
17+
$hostedAgentModulePath = "/usr/share"
18+
$moduleSeperator = ":"
19+
}
20+
$modulePaths = $env:PSModulePath -split $moduleSeperator
21+
$modulePaths = $modulePaths.Where({ !$_.StartsWith($hostedAgentModulePath) })
22+
$AzModuleCachePath = (Get-ChildItem "$hostedAgentModulePath/az_*" -Attributes Directory) -join $moduleSeperator
23+
if ($AzModuleCachePath -and $env.PSModulePath -notcontains $AzModuleCachePath) {
24+
$modulePaths += $AzModuleCachePath
25+
}
26+
27+
$env:PSModulePath = $modulePaths -join $moduleSeperator
28+
29+
Install-ModuleIfNotInstalled "Az.Storage" "4.3.0" | Import-Module
30+
31+
$ctx = New-AzStorageContext `
32+
-StorageAccountName $StorageAccountName `
33+
-UseConnectedAccount
34+
35+
$vcpkgBinarySourceSas = New-AzStorageContainerSASToken `
36+
-Name $StorageContainerName `
37+
-Permission "rwcl" `
38+
-Context $ctx `
39+
-ExpiryTime (Get-Date).AddHours(1)
40+
41+
Write-Host "Ensure redaction of SAS tokens in logs"
42+
Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SAS_TOKEN;issecret=true;]$vcpkgBinarySourceSas"
43+
44+
Write-Host "Setting vcpkg binary cache to read and write"
45+
Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SOURCES_SECRET;issecret=true;]clear;x-azblob,https://$StorageAccountName.blob.core.windows.net/$StorageContainerName,$vcpkgBinarySourceSas,readwrite"
46+
Write-Host "##vso[task.setvariable variable=X_VCPKG_ASSET_SOURCES_SECRET;issecret=true;]clear;x-azurl,https://$StorageAccountName.blob.core.windows.net/$StorageContainerName,$vcpkgBinarySourceSas,readwrite"

eng/vcpkg.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "azure-sdk-for-rust",
3+
"dependencies": [
4+
"openssl"
5+
]
6+
}

sdk/keyvault/azure_security_keyvault_certificates/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ azure_core_test = { workspace = true, features = [
2929
azure_identity.workspace = true
3030
azure_security_keyvault_keys = { path = "../azure_security_keyvault_keys" }
3131
azure_security_keyvault_test = { path = "../azure_security_keyvault_test" }
32+
openssl.workspace = true
3233
rand.workspace = true
3334
tokio.workspace = true
3435

0 commit comments

Comments
 (0)