Skip to content

Instantly share code, notes, and snippets.

@Nillth
Last active August 1, 2024 15:13
Show Gist options
  • Save Nillth/032e7ae397fb886c37f380c9047b2f75 to your computer and use it in GitHub Desktop.
Save Nillth/032e7ae397fb886c37f380c9047b2f75 to your computer and use it in GitHub Desktop.
PowerShell function to Convert PEM files to X509 (PFX) Certificate
<#
.NOTES
===========================================================================
Created by: Marc Collins ([email protected])
Organization: Qlik Professional Services
Filename: Convert-PemtoX509.ps1
===========================================================================
.DESCRIPTION
Converts PEM files to X509 Certificates
Can be used with QlikClient.pems
.Example
$PublicKey = 'C:\ProgramData\Qlik\Sense\Repository\Exported Certificates\.Local Certificates\client.pem'
$PrivateKey = 'C:\ProgramData\Qlik\Sense\Repository\Exported Certificates\.Local Certificates\client_key.pem'
$Cert = Convert-PemtoX509 -PublicKey $PublicKey -PrivateKey $PrivateKey
#>
function Convert-PemtoX509
{
param
(
[Parameter(Mandatory = $true)]
[System.IO.FileInfo]$PublicKey,
[System.IO.FileInfo]$PrivateKey,
[System.IO.FileInfo]$OutPFX,
[securestring]$PFXPassword,
[switch]$NoPassword
)
BEGIN
{
if ($PFXPassword.Length -eq 0 -and $null -ne $OutPFX -and $NoPassword.IsPresent -eq $false)
{
$PFXPassword = Read-Host -Prompt "Enter PFX Password" -AsSecureString
}
[string]$KEY_HEADER = "-----BEGIN RSA PRIVATE KEY-----"
[string]$KEY_FOOTER = "-----END RSA PRIVATE KEY-----";
[System.Security.Cryptography.X509Certificates.X509Certificate2]$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
function Get-RSA
{
param
(
[Parameter(Mandatory = $false)]
[string]$PEM
)
if (Test-IsRSAPrivateKeyAvailable -PEM $PEM)
{
[System.Security.Cryptography.RSAParameters]$PrivateKey = Convert-PEMToRSAParameters -PEM $PEM
[System.Security.Principal.SecurityIdentifier]$everyoneSI = New-Object System.Security.Principal.SecurityIdentifier([System.Security.Principal.WellKnownSidType]::WorldSid, $null)
[System.Security.AccessControl.CryptoKeyAccessRule]$rule = New-Object System.Security.AccessControl.CryptoKeyAccessRule($everyoneSI, [System.Security.AccessControl.CryptoKeyRights]::FullControl, [System.Security.AccessControl.AccessControlType]::Allow)
[System.Security.Cryptography.CspParameters]$cspParameters = New-Object System.Security.Cryptography.CspParameters;
$cspParameters.KeyContainerName = "MY_C_NAME";
$cspParameters.ProviderName = "Microsoft Enhanced RSA and AES Cryptographic Provider";
$cspParameters.ProviderType = 24;
#$cspParameters.Flags = [System.Security.Cryptography.CspProviderFlags]::UseMachineKeyStore;
#$cspParameters.CryptoKeySecurity = New-Object System.Security.AccessControl.CryptoKeySecurity
#$cspParameters.CryptoKeySecurity.SetAccessRule($rule);
[System.Security.Cryptography.RSACryptoServiceProvider]$rsa = New-Object System.Security.Cryptography.RSACryptoServiceProvider($cspParameters);
$rsa.PersistKeyInCsp = $true;
$rsa.ImportParameters($privateKey);
}
return $rsa;
}
function Convert-PEMToRSAParameters
{
param
(
[Parameter(Mandatory = $true)]
[string]$PEM
)
if (Test-IsRSAPrivateKeyAvailable -PEM $PEM)
{
$keyFormatted = $PEM
[int]$cutIndex = $keyFormatted.IndexOf($KEY_HEADER);
$keyFormatted = $keyFormatted.Substring($cutIndex, $keyFormatted.Length - $cutIndex);
$cutIndex = $keyFormatted.IndexOf($KEY_FOOTER);
$keyFormatted = $keyFormatted.Substring(0, $cutIndex + $KEY_FOOTER.Length);
$keyFormatted = $keyFormatted.Replace($KEY_HEADER, "");
$keyFormatted = $keyFormatted.Replace($KEY_FOOTER, "");
$keyFormatted = $keyFormatted.Replace("\r", "");
$keyFormatted = $keyFormatted.Replace("\n", "");
$keyFormatted = $keyFormatted.Trim();
[byte[]]$privateKeyInDER = [System.Convert]::FromBase64String($keyFormatted);
$MemoryStream = New-Object System.IO.MemoryStream( , $privateKeyInDER)
$BinaryReader = New-Object System.IO.BinaryReader( , $MemoryStream)
[System.UInt16]$twobytes = 0;
[int]$elements = 0;
[byte]$bt = 0;
try
{
$twobytes = $binaryReader.ReadUInt16();
if ($twobytes -eq 0x8130)
{
$binaryReader.ReadByte() | Out-Null
}
elseif ($twobytes -eq 0x8230)
{
$binaryReader.ReadInt16() | Out-Null
}
else
{
throw "Wrong data";
}
$twobytes = $binaryReader.ReadUInt16();
if ($twobytes -ne 0x0102)
{
throw "Wrong data";
}
$bt = $binaryReader.ReadByte();
if ($bt -ne 0x00)
{
throw "Wrong data"
}
$elements = Get-IntegerSize($binaryReader)
$paramModulus = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramE = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramD = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramP = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramQ = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramDP = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramDQ = $binaryReader.ReadBytes($elements);
$elements = Get-IntegerSize($binaryReader)
$paramIQ = $binaryReader.ReadBytes($elements);
Assert-Length -Data ([ref]$paramD) -DesiredLength 256
Assert-Length -Data ([ref]$paramDP) -DesiredLength 128
Assert-Length -Data ([ref]$paramDQ) -DesiredLength 128
Assert-Length -Data ([ref]$paramE) -DesiredLength 3
Assert-Length -Data ([ref]$paramIQ) -DesiredLength 128
Assert-Length -Data ([ref]$paramModulus) -DesiredLength 256
Assert-Length -Data ([ref]$paramP) -DesiredLength 128
Assert-Length -Data ([ref]$paramQ) -DesiredLength 128
[System.Security.Cryptography.RSAParameters]$rsaParameters = New-Object System.Security.Cryptography.RSAParameters
$rsaParameters.Modulus = $paramModulus;
$rsaParameters.Exponent = $paramE;
$rsaParameters.D = $paramD;
$rsaParameters.P = $paramP;
$rsaParameters.Q = $paramQ;
$rsaParameters.DP = $paramDP;
$rsaParameters.DQ = $paramDQ;
$rsaParameters.InverseQ = $paramIQ;
return $rsaParameters;
}
finally
{
$BinaryReader.Close() | Out-Null
}
}
}
function Get-IntegerSize
{
param
(
[Parameter(Mandatory = $true)]
[System.IO.BinaryReader]$Binary
)
[byte]$bt = 0;
[byte]$lowbyte = 0x00;
[byte]$highbyte = 0x00;
[int]$count = 0;
$bt = $binary.ReadByte();
if ($bt -ne 0x02)
{
return 0
}
$bt = $binary.ReadByte();
if ($bt -eq 0x81)
{
$count = $binary.ReadByte()
}
elseif ($bt -eq 0x82)
{
$highbyte = $binary.ReadByte();
$lowbyte = $binary.ReadByte();
[byte[]]$modint = $lowbyte, $highbyte, 0x00, 0x00;
$count = [System.BitConverter]::ToInt32($modint, 0);
}
else
{
$count = $bt;
}
while ($binary.ReadByte() -eq 0x00)
{
$count -= 1;
}
$binary.BaseStream.Seek(-1, [System.IO.SeekOrigin]::Current) | Out-Null
return $count;
}
function Assert-Length
{
param
(
[Parameter(Mandatory = $true)]
[ref]$Data,
[Parameter(Mandatory = $true)]
[int]$DesiredLength
)
if ($null -eq $data -or $data.Value.Length -ge $desiredLength)
{
return;
}
[int]$zeros = $desiredLength - $data.Value.Length;
[byte[]]$newData = [byte[]]::new($desiredLength)
[System.Array]::Copy($data.Value, 0, $newData, $zeros, $data.Value.Length);
$data.Value = $newData;
}
function Test-IsRSAPrivateKeyAvailable
{
param
(
[Parameter(Mandatory = $false)]
[string]$PEM
)
return (($null -ne $PEM) -and $PEM.Contains($KEY_HEADER) -and $PEM.Contains($KEY_FOOTER))
}
}
PROCESS
{
if ($PublicKey.Exists)
{
[string]$PEMPublicKey = [System.IO.File]::ReadAllText($PublicKey)
}
if ($PrivateKey.Exists)
{
[string]$PEMPrivateKey = [System.IO.File]::ReadAllText($PrivateKey)
}
[byte[]]$pemCertWithPrivateKey = [System.Text.Encoding]::ASCII.GetBytes($PEMPublicKey)
[System.Security.Cryptography.RSACryptoServiceProvider]$rsaPK = Get-RSA -PEM $PEMPrivateKey
$cert.Import($pemCertWithPrivateKey, "", ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable))
if ($null -ne $rsaPK)
{
$cert.PrivateKey = $rsaPK;
}
}
END
{
if ($null -ne $OutPFX)
{
if ($PFXPassword.Length -gt 0 -and $NoPassword.IsPresent -eq $false)
{
[system.io.file]::WriteAllBytes($OutPFX.fullname, $Cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $PFXPassword))
}
else
{
[system.io.file]::WriteAllBytes($OutPFX.fullname, $Cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx))
}
}
else
{
return $cert;
}
}
}
# SIG # Begin signature block
# MIIrmgYJKoZIhvcNAQcCoIIrizCCK4cCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCD/L6ozJ0FquUsB
# om8coZ7xoD5VIUNPtHyKGL6fEgw+RaCCJHwwggNfMIICR6ADAgECAgsEAAAAAAEh
# WFMIojANBgkqhkiG9w0BAQsFADBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3Qg
# Q0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
# bjAeFw0wOTAzMTgxMDAwMDBaFw0yOTAzMTgxMDAwMDBaMEwxIDAeBgNVBAsTF0ds
# b2JhbFNpZ24gUm9vdCBDQSAtIFIzMRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYD
# VQQDEwpHbG9iYWxTaWduMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
# zCV2kHkGeCIW9cCDtoTKKJ79BXYRxa2IcvxGAkPHsoqdBF8kyy5L4WCCRuFSqwyB
# R3Bs3WTR6/Usow+CPQ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AwLwYJKoZIhvcNAQkE
# MSIEIJmcAdQnCKv7j3HjpDSVSmQJrPNDKhOCZOrkg1LUwi6gMIGkBgsqhkiG9w0B
# CRACDDGBlDCBkTCBjjCBiwQU3Ve1s4c8hhspxq7Ecxr76I11wUkwczBfpF0wWzEL
# MAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExMTAvBgNVBAMT
# KEdsb2JhbFNpZ24gVGltZXN0YW1waW5nIENBIC0gU0hBMzg0IC0gRzQCEAGE06jO
# N4HrV/T9h3uDrrIwDQYJKoZIhvcNAQELBQAEggGAWscAx8Asp0k/OIZe9aSMVEpP
# rrwDVV54QmVnF/wtcNhNdhLOk0FdgHgUMPB40yi8Ct+ZWUpQ73MTlQMcidxv7HYQ
# WVGIZS84n/KKqPDL07iEhxZ/SUUMrBNtdgRKo1pgsdGyKAu+DxYp5p3j4PAoShXv
# BGpwsHtypLykL3WoZ0gax1/p2Wnt8DX8QVSXtdGoNhh6mvwhISf0PAIbPSps3ikY
# keHdi4p0IDhw4P2s9yh9/RqAIgPpprXrU2/yZKhLyjGMWHtBM/ujgr/QhSwJyUBG
# R/KUV20Tn1YJkkNSnNHQYB5PNN2xFbZrno7xlTrfHunElyTRX/kxYBMwtE8IGP6H
# AxprFh4wlXB/xFfW9N9jwRDfwCKcJ+Uv3ueLTsIXUXFaHAsgcYxM2ikbbGqYpIW+
# OR5aZF/QxcHD8UCcMTXhlSiuCq3Q1Q105TZcxep0ykPOUxpDTiqcUQhevHj1lumo
# A5ZpApo5UtyBuInMKXCU3t1oWpV62S/otRR/+0bY
# SIG # End signature block
@shivakirankonduru
Copy link

Does this work when key length is 3072 bits?

@Nillth
Copy link
Author

Nillth commented Jan 19, 2022

if it is a RSA Key, yes it does

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment