2

I'm creating a script to do some repetitious OpenSSL work, but cannot seem to get the batch file to execute the commands.

Once the file has navigated to the correct directory, I try running:

openssl x509 /in:in_cert.cer /inform:DER /out:out_cert.pem /outform:PEM

...but the batch file can't seem to handle it. The slash/colon approach was added after research.

The issue seems to be around the arguments, resulting in an unknown option /in:in_cert.cer error. Note that I've also tried the standard -parameter argument approach as well.

Where am I going wrong with the batch?


Update: the issue isn't in the command itself (I can run it standalone from the command line with -'s instead of /'s... it's getting the command to run within a batch file.

  • To test if it is a batch file issue, have you tried it from the command line? I seriously doubt this is anything to do with batch files. – barlop Jan 13 '15 at 1:28
  • Did you even do openssh -? and openssl /? and see what it said. This linkhas it using dash. ucs.cam.ac.uk/support/windows-support/winsuptech/iis/… – barlop Jan 13 '15 at 1:35
  • Love the downvote. I've definitely tried it from the command line - that's where the result/error was captured. The dash has been replaced after researching about passing arguments in batch file commands (link in original question) - not arbitrarily. openssh doesn't apply; the process is openssl. – jterry Jan 13 '15 at 15:43
3

Answer for any Googlers - the issue was not in the passing of the parameters to openssl, it was in the encoding of the batch file itself.

Once I changed the encoding in my editor (Notepad++) to Windows-1252, the batch ran the commands with ease and didn't need any special /-instead-of-- approach.

  • +1 for solving it but you didn't troubleshoot it very well, you should have tried other commands in the batch file, and no doubt you'd then have realized that within the batch, it wasn't the openssl command specifically. Even dir /? would've given an error if the issue was the encoding and the slash. Though granted nobody suggested that troubleshooting step. – barlop Jan 13 '15 at 21:15
  • Other commands (echo, cd, set, etc) were working- this isn't the first time I've written a batch file :) Glad it's solved and hopefully this'll save some headache for others later. – jterry Jan 13 '15 at 23:32
  • try echo / if the encoding is UTF-8 then it is a bit funny. And dir /? fails. dir /? fails with "'´╗┐dir' is not recognized as an internal or external command, operable program or batch file." with utf-8. What encoding did you have? – barlop Jan 13 '15 at 23:51
  • It was originally set to UTF-8 by default (which didn't raise flags for me) - probably Notepad++'s default encoding... Windows-1252 fixed it. – jterry Jan 14 '15 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.