On Tue, Oct 23, 2012 at 09:05:27AM -0400, thorso...@lavabit.com wrote: > > You did not specify a key to use for this operation. This writes > > a new key to a default file (often privkey.pem) with insecure > > permissions (0644) (even password protected keys should not > > be world readable). > > It saved the key as "cakey.pem" with 644. > > Should I change the permissions of the mentioned files to 600?
Files holding keys (especilly password-less keys) should be 0600. > > So use the "-key filename" option for a key you created, and don't > > go for absurdly long keys that's just silly. > > I tried the following, but I wasn't prompted for a password this > time. How to do it right? If you want a password-protected CA key, add a "-aes128" argument: $ (umask 077; openssl genrsa -aes128 -out keyout.pem 2048) Generating RSA private key, 2048 bit long modulus .............................+++ ..........+++ e is 65537 (0x10001) Enter pass phrase for keyout.pem: Verifying - Enter pass phrase for keyout.pem: Sanity check (optional) showing the right permissions and the right key length (2048/4 = 512 hex nibbles). $ ls -l keyout.pem -rw------- 1 owner group 1766 Oct 23 12:12 keyout.pem $ openssl rsa -noout -modulus -in keyout.pem | perl -pe 's/^Modulus=//' | tee /dev/tty | wc -c Enter pass phrase for keyout.pem: E03D8FE19D0C47BA16388A90569A016AF0D8347E759B1824CC010B80ADDF807FAAF7D9EAE7F3403758EE715C2AE94C8E0C7DE9837CC50285BA6F0BFE5CDD43AAEB487C42405E2E681DE1E8DD0C48CCC04BE7F9B1415026E2A017C88A12122A3500B5F865696534B29CF9577C241BFC44B8BEE076684608119816F1D7379FC58349596ACC0ABC92CC78ED7B8A2F3F1A9484CC7996CBB2EE0FC2AFFA46A648E4B5628CDF6925FB75A1B39E3704CDC2D370B333EA19E9F735294B114997FC08D676E0AA35BFDAED86E675C2B9AB0128B94A0E22057A119AA2A96FD4910EB9DBCEADDAF9C9AF13AACFDAD57F19DC40B11EFC6F9DE593227E647B9A787EF07B769D4D 513 > I'm a bit overwhelmed by all these certs/keys. I understand how it > works in case of SSH, but I have no idea why I need two (Is this > correct?) keys and two certs in this case. A non-trivial certificate chain is not required. You can use a single self-signed server certificate if you prefer. Creating an issuing CA is only useful if you want to sign multiple server certificates, and to configure clients to trust a single private root CA, rather than many private server certs. > How I understand the process: > > $ touch smtpd.key # created a file > $ chmod 600 smtpd.key # changed permissions I just set a umask of 077 around operations that create key files. > $ openssl genrsa 4096 > smtpd.key # generated a 4096 RSA private key Except that 4096 is better replaced by some number between 1280 and 2048, the only reason for the larger of the two at this time is herd mentality. Better to make sure your SSL stack supports forward secrecy the authentication key strength is then secondary, in fact your cert is self-signed, so except for legacy clients that don't implement EDH or ECDH your authentication key strength is irrelevant. > # Generated a new self signed certificate using the private key from > smtpd.key. > # Saved as smtpd.crt. > $ openssl req -new -key smtpd.key -x509 -days 730 -out smtpd.crt > > # Created another certificate (cacert.pem) and a new private key (cakey.pem). > $ openssl req -new -x509 -extensions v3_ca -keyout cakey.pem \ > -out cacert.pem -days 730 > > Is there a need to create a public key? There is no point in CA key that you don't use. If you create a CA, then at least use it to sign the server certificate. Otherwise, both the server key-pair and the CA key-pair are in fact self-signed CAs and one of them is redundant. -- Viktor.