Export Certificate from Windows

Run the following commands in PowerShell to export the certificate into a pfx file with the private key

$password = ConvertTo-SecureString -String "MySupaSecretPassword" -AsPlainText -Force

Get-ChildItem cert:\\localmachine\my

    PSParentPath: Microsoft.PowerShell.Security\Certificate::localmachine\my

Thumbprint                                Subject                                                                     
----------                                -------                                                                                                     
1415949912706E941B63AADCFFEAAA7431233     CN=*.directrouting.guide  

$cert = Get-ChildItem cert:\\localmachine\my\1415949912706E941B63AADCFFEAAA7431233

Export-PfxCertificate -Cert $cert  -FilePath .\wildcard.pfx -Password $password

Import the pfx into the SBC

Option 1 - Manually import certificate on Web Gui

  1. Log onto AudioCodes Mediant via Web GUI
  2. Select Setup -> IP Network -> Security ->TLS Context
  3. select context and then select change cert
  4. Under “Upload certificates from you computer”
    • enter password from step 1 in pass-phrase
    • Browse for privake key and select pfx file in step 1
    • select load file

Option 2 - Create a web server to host pfx and upload via telnet

If you want to do it all from the command line, then you can follow this process

Step 1. Open a PowerShell as administrator


Step 2. Create a temporary firewall rule to allow port 80

New-NetFirewallRule -DisplayName 'HTTP TEMP' -Direction Inbound -Action Allow -Protocol TCP -LocalPort '80'

Step 3. Create Web Service

    Add-Type -AssemblyName System.Web

    $listener = New-Object System.Net.HttpListener

    $context = $listener.GetContext()
    Write-verbose "Getting -> $($context.Request.Url.LocalPath)" -Verbose
    $URL = $Context.Request.Url.LocalPath
    $Content = Get-Content  -Path (join-path $PWD.Path $URL) -Encoding Byte
    $Context.Response.ContentType = [System.Web.MimeMapping]::GetMimeMapping("$URL")
    $Context.Response.OutputStream.Write($Content, 0, $Content.Length)

Step 4. Telnet to server and copy cert from http


copy tls-private-key from context 0 pass-phrase MySupaSecretPassword

Step 5. Clean up #IMPORTANT

Remove-NetFirewallRule -DisplayName 'HTTP TEMP'