Skip to content

Commit 14f217d

Browse files
author
Greg Brownstein
committed
workaround no longer needed
1 parent 6570624 commit 14f217d

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

VenafiPS/Public/Import-VdcCertificate.ps1

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,28 +235,22 @@ function Import-VdcCertificate {
235235
end {
236236
Invoke-VenafiParallel -InputObject $allCerts -ScriptBlock {
237237

238-
$certData = $PSItem.Data
239-
if ( $PSItem.Path ) {
240-
if ((([System.IO.Path]::GetExtension($PSItem.Path)) -in '.pfx', '.p12') -and $PSItem.InvokeParams.Body.Password ) {
241-
242-
# tpp won't accept a p12 and password so use this workaround to decrypt first
243-
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($PSItem.Path, $PSItem.InvokeParams.Body.Password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
244-
$certData = [System.Convert]::ToBase64String( $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12))
238+
$thisItem = $PSItem
245239

240+
$certData = if ( $thisItem.Path ) {
241+
$cert = if ($PSVersionTable.PSVersion.Major -lt 6) {
242+
Get-Content $thisItem.Path -Encoding Byte
246243
}
247244
else {
248-
249-
if ($PSVersionTable.PSVersion.Major -lt 6) {
250-
$cert = Get-Content $PSItem.Path -Encoding Byte
251-
}
252-
else {
253-
$cert = Get-Content $PSItem.Path -AsByteStream
254-
}
255-
$certData = [System.Convert]::ToBase64String($cert)
245+
Get-Content $thisItem.Path -AsByteStream
256246
}
247+
[System.Convert]::ToBase64String($cert)
248+
}
249+
else {
250+
$thisItem.Data
257251
}
258252

259-
$params = $PSItem.InvokeParams
253+
$params = $thisItem.InvokeParams
260254
$params.Body.CertificateData = $certData
261255

262256
try {

0 commit comments

Comments
 (0)