I have created a self signed certificate using Powershell's New-SelfSignedCertificate, with the intention of encrypting and storing a username / password in public.
Specifically using -
New-SelfSignedCertificate -TextExtension @("2.5.29.37={text}1.3.6.1.4.1.311.80.1")
-Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"
-DnsName sign.example.com
-CertStoreLocation "Cert:\CurrentUser\My"
-KeyExportPolicy ExportableEncrypted -KeyUsage DataEncipherment
-KeyUsageProperty All -KeyLength 2048
$key = New-Object byte[](32)
$rng = [System.Security.Cryptography.RNGCryptoServiceProvider]::Create()
$rng.GetBytes($key)
$SecureStringWithKey = $cred.Password | ConvertFrom-SecureString -Key $key
I am then creating an object with the key, username and password securestring and encrypting it through
Protect-CmsMessage -Content $object -To $thumbprint
Presuming that I have used a complex password for the pfx file, is it safe to store the pfx file and the encrypted string together in a github repository (along with the script that untangles the whole thing) or should I be taking steps to keep the pfx file safe also?