eric0012
eric0012

Reputation: 9

Making openssl macros in linux with C

I am trying to create an automation system for renewing ssl cert using openssl on linux. The method I decided to go with was created a C program, with my first step being to have the program run the initiating openssl command and autofill in the fields that proceed after with variables that I predefined. How do accomplish this? I understand how to run basic commands from C using system(), but i am not sure how to have it continue to enter the actual fields

Upvotes: -1

Views: 114

Answers (1)

larsks
larsks

Reputation: 311238

I think you've probably selected the most complicated solution possible. First, if you're primarily just going to be calling other programs, C isn't going to get you much. Second, you absolutely don't want to try to fill in interactive prompts if you can avoid it (and you can!).

For example, to create a CSR for server.example.com without any interactive prompting, we can run something like:

openssl req -nodes -newkey rsa:4096 -keyout server.key -out server.csr \
  -sha256 -days 365 -subj /CN=server.example.com

This creates server.key and server.csr.

Lastly, for certificate renewal, you should just be able to re-use an existing CSR.

Upvotes: 0

Related Questions