Reputation: 17915
I'm trying to create batch file for WINDOWS to automate creation of self-signed certificate. Following this tutorial: http://www.xenocafe.com/tutorials/linux/centos/openssl/self_signed_certificates/index.php
I wrote following script:
@echo off
REM This script takes name passed in and generates private and public keys using OpenSSL
REM First parameter expects name
IF "%1"=="" GOTO EXIT
ECHO Generating PRIVATE key ------------------------------
openssl genrsa -des3 -out %1.key 1024
ECHO Creating certificate sign request (CSR) -------------
openssl req -key %1.key -out %1.csr
ECHO Signing CSR 100 years -------------------------------
openssl x509 -req -days 36500 -in %1.csr -signkey %1.key -out %1.crt
ECHO Create a kopy of password-protected key -------------
cp %1.key %1.key.secure
ECHO Remove password from private key --------------------
openssl rsa -in %1.key.secure -out %1.key
Idea is to get private key with no password and public key for distribution. I run CMD prompt under admin rights and here is what I get:
Just hands there, doesn't ask about country code, etc..
Upvotes: 10
Views: 6277
Reputation: 9
putting winpty infront of my generate command stopped it from hanging
winpty openssl genrsa -aes256 -out clientprivate.key 2048
Upvotes: -1
Reputation: 17915
It should have -new
:
ECHO Creating certificate sign request (CSR) -------------
openssl req -new -key %1.key -out %1.csr
Upvotes: 7