Skip to content

Commit 508dda6

Browse files
authored
[Ci]: Support to sign image for cisco-8000 uefi secure boot (#10616)
Why I did it [Ci]: Support to sign image for cisco-8000 uefi secure boot
1 parent 37e2848 commit 508dda6

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
parameters:
2+
- name: connectionName
3+
type: string
4+
default: sonic-dev-connection
5+
- name: kevaultName
6+
type: string
7+
default: sonic-kv
8+
- name: certificateName
9+
type: string
10+
default: sonic-secure-boot
11+
12+
steps:
13+
- task: AzureKeyVault@2
14+
inputs:
15+
connectedServiceName: ${{ parameters.connectionName }}
16+
keyVaultName: ${{ parameters.kevaultName }}
17+
secretsFilter: ${{ parameters.certificateName }}
18+
19+
- script: |
20+
set -e
21+
TMP_FILE=$(mktemp)
22+
echo "$CERTIFICATE" | base64 -d > $TMP_FILE
23+
sudo mkdir -p /etc/certificates
24+
mkdir -p $(Build.StagingDirectory)/target
25+
# Save the public key
26+
openssl pkcs12 -in $TMP_FILE -clcerts --nokeys -nodes -passin pass: | sed -z -e "s/.*\(-----BEGIN CERTIFICATE\)/\1/" > $(SIGNING_CERT)
27+
# Save the private key
28+
openssl pkcs12 -in $TMP_FILE -nocerts -nodes -passin pass: | sed -z -e "s/.*\(-----BEGIN PRIVATE KEY\)/\1/" | sudo tee $(SIGNING_KEY) 1>/dev/null
29+
ls -lt $(SIGNING_CERT) $(SIGNING_KEY)
30+
rm $TMP_FILE
31+
env:
32+
CERTIFICATE: $(${{ parameters.certificateName }})
33+
displayName: "Save certificate"

.azure-pipelines/official-build-cisco-8000.yml

+13
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ resources:
2222
name: Cisco-8000-sonic/platform-cisco-8000
2323
endpoint: cisco-connection
2424

25+
2526
variables:
2627
- group: SONIC-AKV-STROAGE-1
2728
- name: StorageSASKey
2829
value: $(sonicstorage-SasToken)
30+
- name: SONIC_ENABLE_SECUREBOOT_SIGNATURE
31+
value: y
32+
- name: SIGNING_KEY
33+
value: /etc/certificates/sonic-secure-boot-private.pem
34+
- name: SIGNING_CERT
35+
value: $(Build.StagingDirectory)/target/sonic-secure-boot-public.pem
2936

3037
stages:
3138
- stage: Build
@@ -41,6 +48,7 @@ stages:
4148
parameters:
4249
buildOptions: 'USERNAME=admin SONIC_BUILD_JOBS=$(nproc) ${{ variables.VERSION_CONTROL_OPTIONS }}'
4350
preSteps:
51+
- template: azure-pipelines-download-certificate.yml
4452
- checkout: self
4553
submodules: recursive
4654
path: s
@@ -90,5 +98,10 @@ stages:
9098
StorageSASKey: $(StorageSASKey)
9199
condition: ne(variables['Build.Reason'], 'PullRequest')
92100
displayName: "Override cisco sai packages"
101+
- script: |
102+
echo "SONIC_ENABLE_SECUREBOOT_SIGNATURE := y" >> rules/config.user
103+
echo "SIGNING_KEY := $(SIGNING_KEY)" >> rules/config.user
104+
echo "SIGNING_CERT := $(SIGNING_CERT)" >> rules/config.user
105+
displayName: "Enable secure boot signature"
93106
jobGroups:
94107
- name: cisco-8000

0 commit comments

Comments
 (0)