Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide instructions for creating certificate on Windows #26

Open
me21 opened this issue Nov 20, 2018 · 3 comments
Open

Provide instructions for creating certificate on Windows #26

me21 opened this issue Nov 20, 2018 · 3 comments
Labels

Comments

@me21
Copy link

me21 commented Nov 20, 2018

Certificates can be created on Windows with OpenSSL like this:

First, generate CA certificate:

C:\OpenSSL-Win32\bin\openssl req -x509 -new -key rootCA.key -days 10000 -out rootCA.crt

Then create cmd script with the following content:

C:\OpenSSL-Win32\bin\openssl req -newkey rsa:2048 -out %1.csr -keyout %1.key -nodes -subj "/C=US/ST=GE/L=location/O=organisation/CN=%1"
if "%~2"=="" (
  set SAN=DNS:%1
) else (
  set SAN=DNS:%2
)
C:\OpenSSL-Win32\bin\openssl x509 -req -in %1.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out %1.crt -days 5000 -extfile extfile.cnf
C:\OpenSSL-Win32\bin\openssl x509 -in %1.crt -out %1.crt.der -outform der
C:\OpenSSL-Win32\bin\openssl rsa -in %1.key -out %1.key.der -outform der

Save this snippet to create_new_cert.cmd file and run it as create_new_cert elabel.local. It will create new certificate named elabel.local.crt and corresponding key too. It will use DNS:elabel.local also for subjectAltName field of the certificate.
If run with two arguments (create_new_cert filename dnsname), it will create certificate with the corresponding filename and put DNS:dnsname into subjectAltName field of the certificate.

You may further tailor the script as you need.

@fhessel
Copy link
Owner

fhessel commented Dec 2, 2018

Thanks for providing the code!

Did you also found a way to convert the cert and key files to C headers, so that one could create a complete Windows version of create_cert.sh that generates the same outputs? I don't have a Windows machine at hand, so I can't check that by myself.

@fhessel fhessel added the feature label Dec 2, 2018
@me21
Copy link
Author

me21 commented Dec 2, 2018

There are many results when googling for "bin2c", here's one link: https://www.segger.com/free-utilities/bin2c/

@flywire
Copy link

flywire commented Jul 8, 2019

First, generate CA certificate:

After Create Root Key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants