Jump to content
Alex

ANSWERED Export Certificate to file

Recommended Posts

Hi,

 

I would like to export a remote connector client certificate via powershell.

 

Connect-IpPbx
$u = Get-IpPbxUser -UserId 14
$c = Get-IpPbxClientCertificate -UserEntry $u
 

Ok now I have a X509Certificate Object. But how can I write this as pfx to a file?

Thx Alex

Edited by Alex

Share this post


Link to post
Share on other sites

Hello Alex,

 

the following Powershell snippet should solve your problem 😄

Connect-IpPbx
$destinationFilePath = Join-Path -Path $env:USERPROFILE "Downloads\Sebastian.pfx"
$cert = Get-IpPbxUser -UserName Sebastian | Get-IpPbxClientCertificate
$certData = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, "123456")
[System.IO.File]::WriteAllBytes($destinationFilePath, $certData)
Disconnect-IpPbx 

 

Share this post


Link to post
Share on other sites

There's an easier way using built-in PowerShell functionality ;-)

 

Export-PfxCertificate -Cert $c -Password (Read-Host -Prompt "Password" -AsSecureString) -FilePath ./clientcert.pfx

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.