Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Create Base64 string cert like this (note that X509KeyStorageFlags.Exportable required to export pfx with pritave key)
# X509Certificate2 cert = new X509Certificate2(<path_to_pfx>, <password>, X509KeyStorageFlags.Exportable);
# string base64Str = Convert.ToBase64String(cert.Export(X509ContentType.Pfx));
# Next store it as a secire variable named certStr in Appveyor project config
# Then use it during a build.
environment:
certStr:
secure: BWrNTKG4xirH2oPN32DOiRmnitc4S9VFYvV3wAqmA1Qsb7h92ke2YzUox8qmLWd7WJ1vu4qDjCvUweSzhGVdupg+FU8dCUMxXLN86ytGVRxCAojuXR/IyvG3J0ibxTt4ZRZc3pPinHbaz8xqe7l3uGJQDJIKlbUjglvYaptjupkEzvH8im0QOa44yFXCpZVsn/kXCCYPgA6nF7TP0YszLx0EtdNB63nWG3eOaf6CXwabOmwMzXxOZa38+vGdrC2RrRM9xnJeheTuY+FKZZ3Xxk0r4rEKQJUYj55e5mt+czaJ0YJynUMxljWgTVs/nvIMkcKirkIOFs9RxtHM+/3tEDGKDSzxG0td7hLks2tLscLxhYZBri851U3O2vRGBu6wmhYQanfB5w7eaVnV4sIJrneLnV++3EpplguiRKA1LEmQ+fpj6Gdt4Y8aGGTGm0vDflcmKdIdNAIQY0hLs4qop7VrAmlvo+RmQq3il10uhk4pOmIwXSBIuZxKRzxjgsFRJwQOHUNV/I6LM3LLPUKP7bsWSaGPloy+RUmUSU7s9oB4cFAP21XyDzusHoFuqwCM1C6JASANYQmNefWLZySSFkpoM+8mAMWH25lWVvxduRkgBuEFlIQJQRGA+Y5qEyWzYiLKmRTD7CwAvSj8/Y8W6VJXoe60B5xm8ITBVZROSxuzpvgtRi36b0QOheycfwz/C2e9KC/nuwTs11LJgheN+0XX7Tj22rY+bWxCKAnxdjfkjtArSVQxkobVFRYjacBYGQxF8rTQBO/AgqGx8qzZpxbDGCoNvJWk+B5q1KtHxgCwawcV88KBscCfg5xAkPCB911knf832V/sOYyj4fyDpIrjNCKZ7BrthJs2AWT0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btF6+hwSqoBMRaIZVgiuXpJExx4BRccEUBk5VcLbMk6xzAmwR2C5nCQhRWV3cwHzABgCcHy6K2+quaFYY0Lj7SHDRRRIX/Dgqr4NnsbkSomr56nZVyjW14etsyQPmF8lrY+90rh7C5kzg+frNVmFTrERwlUEomsjcZTx1dHwY8o9cnREO1V58Q1J7nYfcWpApswQJu2UBaJ4HIieRuzJ6hkQ6iVgK+rMlqijMEo3klvkCkDogA+tz9j9/H3NDl4VZGO7xZ2COG82vbMjP5zVNR7ay/P6g7hQaCR/OMYWDBiCD6vrYBGeM/uDqctUqiF/LzP61pYG+n31ySSc+8ImDJelrwezZzUPX90XiF/SoF2LQKqA==
install:
#use it as PFX file
- ps: >-
$bytes = [System.Convert]::FromBase64String($env:certStr)
[System.IO.File]::WriteAllBytes("$env:APPVEYOR_BUILD_FOLDER\myCert.pfx", $bytes)
#or use as X509 cert and install to store
- ps: >-
$bytes = [System.Convert]::FromBase64String($env:certStr)
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($bytes)
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My", "CurrentUser");
$store.Open("ReadWrite");
$store.Add($cert)
$store.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment