@@ -7,13 +7,19 @@ environment:
7
7
install :
8
8
- ps : >-
9
9
Write-Host -ForegroundColor Yellow "Install 'secure-file' tool..."
10
+
10
11
nuget install secure-file -ExcludeVersion
11
12
13
+
12
14
Write-Host -ForegroundColor Yellow "Decrypt UnitsNet.pfx..."
15
+
13
16
.\secure-file\tools\secure-file -decrypt Build\UnitsNet.pfx.enc -secret $env:UnitsNetPfxEncSecret
14
17
18
+
15
19
$pfx = Resolve-Path "Build\UnitsNet.pfx"
20
+
16
21
$password = $env:UnitsNetPfxSecret
22
+
17
23
$keyContainerName = "VS_KEY_53797375DF3695DD"
18
24
19
25
@@ -22,20 +28,31 @@ install:
22
28
Write-Host -ForegroundColor Yellow "Import $pfx ..."
23
29
24
30
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
31
+
25
32
$cert.Import($pfx, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
33
+
26
34
$exportPrivateKeyInformation = $true
35
+
27
36
$certXml = $cert.PrivateKey.ToXmlString($exportPrivateKeyInformation)
28
37
38
+
29
39
$csp = New-Object System.Security.Cryptography.CspParameters
40
+
30
41
$csp.KeyContainerName = $keyContainerName
42
+
31
43
$csp.Flags = [System.Security.Cryptography.CspProviderFlags]::UseMachineKeyStore -bor [System.Security.Cryptography.CspProviderFlags]::NoPrompt # -bor is biwise or
44
+
32
45
$csp.KeyNumber = [System.Security.Cryptography.KeyNumber]::Signature
33
46
47
+
34
48
$rsa = New-Object System.Security.Cryptography.RSACryptoServiceProvider $csp
49
+
35
50
$rsa.FromXmlString($certXml)
51
+
36
52
$rsa.Clear()
37
53
38
- Write-Host -ForegroundColor Yellow "Sucesfully imported $pfx into StrongName CSP store"
54
+
55
+ Write-Output "Sucesfully imported $pfx into StrongName CSP store"
39
56
build_script :
40
57
- ps : >-
41
58
#####################################
0 commit comments