147

What is the purpose of the -nodes argument in openssl?

5
  • 2
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask.
    – jww
    Apr 1, 2015 at 10:54
  • 33
    @jww I disagree, openssl is a low-level toolkit and developers have to deal with it all the time. The line is fairly blurry, and it would be a big loss to not allow openssl questions here simply because it happens to be a CLI rather than the C lib.
    – gtd
    Apr 16, 2015 at 19:45
  • @gtd - that's a frequent complaint when I flag these. Also see Where do I post questions about Dev Ops?. (But I think I made a mistake on this one - the question is from 2011, and I believe its was on-topic back then. I don't like to penalize for the policy change).
    – jww
    Apr 16, 2015 at 19:52
  • 2
    @gtd - re: "openssl is a low-level toolkit and developers have to deal with it all the time." - that's what Super User or Unix & Linux Stack Exchange are for. "... it would be a big loss to not allow openssl questions ..." - openssl C programming questions are always welcomed here. The loss of the non-programming questions will not be missed because Stack Overflow is a programming and development site. There's other sites to go to when you don't know how to use a command.
    – jww
    Apr 16, 2015 at 19:55
  • Thanks for the link, I'll post my response there since I think this is a very important issue.
    – gtd
    Apr 16, 2015 at 20:01

2 Answers 2

172

The option -nodes is not the English word "nodes", but rather is "no DES". When given as an argument, it means OpenSSL will not encrypt the private key in a PKCS#12 file.

To encrypt the private key, you can omit -nodes and your key will be encrypted with 3DES-CBC. To encrypt the key, OpenSSL prompts you for a password and it uses that password to generate an encryption key using the key-derivation function EVP_BytesToKey.

Depending on your version of OpenSSL and compiled options, you may be able to provide these options in place of -nodes:

-des          encrypt private keys with DES
-des3         encrypt private keys with triple DES (default)
-idea         encrypt private keys with idea
-seed         encrypt private keys with seed
-aes128, -aes192, -aes256
              encrypt PEM output with cbc aes
-camellia128, -camellia192, -camellia256
              encrypt PEM output with cbc camellia

Ultimately at the library level OpenSSL calls the function PEM_write_bio_PrivateKey with the encryption algorithm (or lack thereof) you choose.

4
  • 2
    By encrypt, do you mean with a password?
    – Flimm
    Apr 12, 2013 at 8:50
  • 4
    @Flimm: Protected with a password, yes. The password generates an encryption key using a key-derivation algorithm, and the encryption is done with the key, not the password. The only way to use the encrypted key is to decrypt it first, for which you need to know the password it was encrypted with to generate the same key.
    – indiv
    Apr 12, 2013 at 14:42
  • 1
    why shoulud I encrypt my private key file? those arent published to anyone, hence the name. Or am I wrong?
    – phil294
    Sep 25, 2018 at 2:20
  • 2
    @Blauhirn: You'd encrypt your private key file for the same reason you'd encrypt any file: you don't want someone who obtains a copy to be able to read it or use it. Whether you should encrypt the private key depends on the importance of the key and your threat model.
    – indiv
    Sep 25, 2018 at 17:48
16

edit: nginx v1.7.3 has added an ssl_password_file directive which reads passphrases from a specified file trying each passphrase on the context's encrypted-private.key

indiv is correct that the -nodes argument means that OpenSSL will create UNencrypted private.key; otherwise, there will be a passphrase prompt to create encrypted-private.key. see req, pkcs12, CA.pl

however, I feel the purpose (for programmers) is because:

  • HTTP servers (e.g. Apache, Nginx) cannot read encrypted-private.key without passphrase →
    • Option A - each time HTTP server starts, must provide passphrase for encrypted-private.key
    • Option B - specify ssl_password_file file.keys; in http { } or server { } context. [ref]
    • Option C - use -nodes to create private.key without encryption

useful: lock down private.key

  • { add HTTP server to ssl-cert group }
  • sudo chown root:ssl-cert private.key - change owner of private.key to root user, ssl-cert group
  • sudo chmod 640 private.key - change access permissions of private.key to owner R/W, group R
  • now, HTTP server should be able to start and read UNencrypted private.key

Option A

stronger security, yet when server restarts, have to manually type in passphrase for encrypted-private.key

Option B

medium security, and probably good balance between A/C

Option C

weaker security, yet NOT prompted for UNencrypted private.key passphrase

3
  • 1
    Nginx can read encrypted private keys since version 1.7.3, see: nginx.org/en/docs/http/…
    – 5lava
    Nov 19, 2014 at 18:31
  • 2
    What is the purpose of bringing nginx and its versions into the discussion? Also, (B) and (C) offer equivalent security (namely, filesystem ACLs). The problem you are describing is the Unattended Key Storage Problem, and its a problem without a solution. See Gutmann's Engineering Security book.
    – jww
    Apr 1, 2015 at 10:58
  • @jww the question asks "what is the purpose...". I considered the question's context (QnA for programmers), which I attempted to indicate via "however, I feel the purpose (for programmers) is because:". specifically regarding security.. may be a discussion for security.stackexchange.com Apr 2, 2015 at 11:47

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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