Search code examples
windowssslcertificate

Convert filetype of cert from .txt to .pem


I need to add a server certificate to my trust store, and therefore a .pem file has been provided to me on github. Unfortunately, for some reason, i can't download the file, so i have copied the text and inserted the text into a .txt file. Now, i need assume that i have to convert filetype from .txt to .pem, before i can add the server certificate to my trust store in windows 10.

How do i convert a certificate in .txt to .pem? I am using windows 10

The file looks like the following:

-----BEGIN CERTIFICATE-----
xxx
xxx
...
-----END CERTIFICATE-----

Solution

  • As IInspectable pointed out it is not really a programming question as you could just use the context menu of Windows explorer or hit F2 on the selected file.

    But of course this issue can be handled programmatically - here is the PowerShell way:

    1. Open a PowerShell console window.
    2. Run:
      Move-Item 'C:\my-file.txt' 'C:\my-file.pem'