Skip to content

Commit fd3ac6a

Browse files
authored
fix win cert (#547)
1 parent c7ac406 commit fd3ac6a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

.github/workflows/ci.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,9 @@ jobs:
190190
- name: run PubSub sample
191191
run: |
192192
python ./utils/run_in_ci.py --file ./.github/workflows/ci_run_pubsub_cfg.json
193-
# TODO Temporarily disable this job. Enable it after the issue is properly fixes.
194-
# - name: run Windows Certificate Connect sample
195-
# run: |
196-
# python ./utils/run_in_ci.py --file ./.github/workflows/ci_run_windows_cert_connect_cfg.json
193+
- name: run Windows Certificate Connect sample
194+
run: |
195+
python ./utils/run_in_ci.py --file ./.github/workflows/ci_run_windows_cert_connect_cfg.json
197196
- name: configure AWS credentials (MQTT5)
198197
uses: aws-actions/configure-aws-credentials@v2
199198
with:

utils/run_in_ci.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ def make_windows_pfx_file(certificate_file_path, private_key_path, pfx_file_path
147147

148148
# Import the PFX into the Windows Certificate Store
149149
# (Passing '$mypwd' is required even though it is empty and our certificate has no password. It fails CI otherwise)
150-
import_pfx_arguments = ["powershell.exe", "Import-PfxCertificate", "-FilePath", pfx_file_path, "-CertStoreLocation", "Cert:\\" + pfx_certificate_store_location, "-Password", "$mypwd"]
150+
import_pfx_arguments = [
151+
"powershell.exe",
152+
# Powershell 7.3 introduced an issue where launching powershell from cmd would not set PSModulePath correctly.
153+
# As a workaround, we set `PSModulePath` to empty so powershell would automatically reset the PSModulePath to default.
154+
# More details: https://github.com/PowerShell/PowerShell/issues/18530
155+
"$env:PSModulePath = '';",
156+
"Import-PfxCertificate",
157+
"-FilePath", pfx_file_path,
158+
"-CertStoreLocation",
159+
"Cert:\\" + pfx_certificate_store_location,
160+
"-Password",
161+
"$mypwd"]
151162
import_pfx_run = subprocess.run(args=import_pfx_arguments, shell=True, stdout=subprocess.PIPE)
152163
if (import_pfx_run.returncode != 0):
153164
print ("ERROR: Could not import PFX certificate into Windows store!")

0 commit comments

Comments
 (0)