Skip to content

Instantly share code, notes, and snippets.

@armsp
Created May 6, 2018 07:29
Show Gist options
  • Save armsp/db57de8e48578b25965cef80cfa6cfd5 to your computer and use it in GitHub Desktop.
Save armsp/db57de8e48578b25965cef80cfa6cfd5 to your computer and use it in GitHub Desktop.
Automate certificate conversion from .cer to .pem via openssl using Python. An automated solution for Docker issue error x509: certificate signed by unknown authority
import os
path = "C:/Users/username/path/to/your/folder"
file_list = os.listdir(path)
file_list_no_extension = [os.path.splitext(x)[0] for x in file_list]
for i,j in zip(file_list,file_list_no_extension):
command_list = []
command1 = "openssl x509 -inform der -in "
command2 = " -out "
command3 = ".pem"
command_list.append(command1)
command_list.append(i)
command_list.append(command2)
command_list.append(j)
command_list.append(command3)
final_command = "".join(command_list)
os.syatem(final_command)
#print(final_command)
#openssl x509 -inform der -in certificate.cer -out certificate.pem
@armsp
Copy link
Author

armsp commented May 6, 2018

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