Hot answers tagged

96

Edit: This is by far my most popular answer, and it's been a few years on now so I've added an ECDSA variant. If you can use ECDSA you should. You can supply all of that information on the command line. One step self signed passwordless certificate generation: RSA Version openssl req \ -new \ -newkey rsa:4096 \ -days 365 \ -nodes \ ...


50

Yes, it's a mandatory step. You cannot remove OpenSSL from a program uses it, the same way you couldn't remove random engine parts from a car. The OpenSSL library is usually already installed, but you have to install the header files. Depending on your Linux distribution, you'll need these packages: Red Hat, Fedora, CentOS - openssl-devel Debian, Ubuntu - ...


47

No, Heartbleed doesn't really affect SSH keys, so you probably don't need to replace the SSH keys you've been using. First, SSL and SSH are two different security protocols for two different uses. Likewise, OpenSSL and OpenSSH are also two completely different software packages, despite the similarities in their names. Second, the Heartbleed exploit causes ...


41

It's possible to convert your ssh public key to PEM format(that 'openssl rsautl' can read it): Example: ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PKCS8 > id_rsa.pem.pub Assuming 'myMessage.txt' is your message which should be public-key encrypted. Then just encrypt your message with openssl rsautl and your converted PEM public-key as you would ...


24

Edit: This question was closed as a duplicate of OpenSSL without prompt. See my accepted answer there as well. This answer has now been updated with an ECDSA variant as well. If you can use ECDSA you should. You need to specify the subject as part of your command. This command is one step, non-interactive, self-signed certificate creation. RSA version ...


18

The documentation wasn't very clear to me, but it had the answer, the challenge was not being able to see an example. Here's how to do it: openssl aes-256-cbc -in some_file.enc -out some_file.unenc -d -pass pass:somepassword Notice that the command line command syntax is always -pass followed by a space and then the type of passphrase you're providing, ...


15

Do openssl pkcs8 -topk8 to convert a private key from traditional format to pkcs#8 format. This format -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY----- is referred to as "SSLeay format" or "traditional format" for private key. I'm not sure which format your key is, so I'll demonstrate the idea with a private key generated by genrsa. ...


15

By definition, a self-signed certificate can be trusted only through direct trust, i.e. what Web browsers like Firefox show as the "allow exception" process. One very specific certificate, down to the last bit, is declared as "trusted". Nothing can be changed in a certificate without exiting from this model, and, in particular, the expiry date, which is part ...


12

A certificate has only the public key, not the private one. When they're in PEM format, sometimes both the private key and the certificate are in the same file. Look for a BEGIN PRIVATE KEY or BEGIN RSA PRIVATE KEY header. If you find one, just separate the two blobs using a regular text editor. But if you have only the certificate, then you absolutely ...


11

This adds the challengePassword attribute to the certificate request, described in PKCS#9 section 5.4.1: 5.4.1 Challenge password The challengePassword attribute type specifies a password by which an entity may request certificate revocation. The interpretation of challenge passwords is intended to be specified by certificate issuers etc; no ...


11

If a keyfile uses a passphrase it has "Proc-Type:" attribute set with the word "ENCRYPTED" appended. So, you can determine if a keyfile uses passphrase by running it through find and grep to see if it has the string 'ENCRYPTED'. # list keyfiles that USE a passphrase HOMES=/home /mnt/nfs_home find $HOMES -maxdepth 3 -type f -path '*/.ssh/id* -name ...


10

Because you are asking it to encrypt the private key by giving the -des3 option. If you don't want your key to be protected by a password, remove the -des3 option from the command line.


10

To restart PHP on IIS, you actually need to restart IIS: Click Start, click Run, type IISReset, and then click OK.


10

Its a bug in OSX. You can import from the command line as per this answer: http://stackoverflow.com/a/11979625/59198 The command is: security import pub_key.pem -k ~/Library/Keychains/login.keychain You'll then need to rename the key in keychain.app


10

I don't know of an easy to use command-line switch, but in the openssl s_client command line, you can add the -msg option to get an hexadecimal dump of the handshake message. Then look for the ServerKeyExchange message; it should look like this: <<< TLS 1.2 Handshake [length 030f], ServerKeyExchange 0c 00 03 0b 01 00 ff ff ff ff ff ff ff ff c9 ...


9

I had the same issue and wrote this... It's quick and dirty, but should work. It'll log (and print to screen with debugging on) any certs which aren't yet valid or expire in the next 90 days. Might contain some bugs, but feel free to tidy it up. #!/bin/sh DEBUG=false warning_days=90 # Number of days to warn about soon-to-expire certs ...


7

Private keys should have reading heavily restricted. Setting permissions to 600 and owned by root should work. However, there are other secure permissions settings - Ubuntu stores keys in a directory with owner root and group ssl-cert and permissions 710. This means that only members of ssl-cert can access any files in that directory. Private keys then have ...


7

The compiled version will depend on the system. If you compile it on two different systems you will get two different versions of the binary. For this reason OpenSSL only provides sources: otherwise they should build it for all the major systems and versions. Binaries are usually distributed with the system or as an add-on package. Each Linux distribution ...


7

You should: Update your system to the latest OpenSSL version Generate new keys and certificates for services relying on OpenSSL and restart them Revoke former certificates Invalidate all established sessions


7

Yes! Know and let others know that all information might have been revealed that was encrypted only by HTTPS for many web servers around the world. You should contact your service providers and confirm that they have plans or have already taken the necessary steps to correct the vulnerability (presuming they were susceptible to it). This especially ...


7

From https://www.openssl.org/news/vulnerabilities.html CVE-2014-0160 (OpenSSL advisory) 7th April 2014: A missing bounds check in the handling of the TLS heartbeat extension can be used to reveal up to 64kB of memory to a connected client or server (a.k.a. Heartbleed). This issue did not affect versions of OpenSSL prior to 1.0.1. Reported by Neel ...


6

At least on Linux, 104 is ECONNRESET for "Connection reset by peer" – in other words, the connection was forcibly closed with a TCP RST packet, either sent out by the server or spoofed by an intermediary. I would try Wireshark/tshark on the Ubuntu server to see what actually gets sent. If the RST is real, it could be that the httpd process died ...


6

*nix commands usually use a dash to represent stdin or stdout in the context of file parameters, so -key - is supposed to read the key from stdin. However, it seems that openssl doesn't implement this. Luckily, in Linux pretty much everything is a file, including stdin which can be accessed as /dev/stdin (which is actually a symlink to /proc/self/fd/0), so ...


6

Below is my script that as a check within nagios. It connects to a specific host, it verifies that the certificate is valid within a threshold set by the -c/-w options. It can check that the CN of the certificate matches the name you expect. You need the python openssl library, and I did all the testing with python 2.7. It would be trivial to have a ...


6

To add those directives to Apache via WHM you'd add them via : Apache Configuration > Include Editor > Pre Main Include and of course with the new issue with Poodle and disabling SSL v3 you'd probably want to make it : SSLProtocol ALL -SSLv2 -SSLv3 SSLHonorCipherOrder On SSLCipherSuite ...


6

The following configuration is (or used to be) the best configuration according to SSLLabs: SSLProtocol +TLSv1.2 +TLSv1.1 +TLSv1 SSLCompression off SSLHonorCipherOrder on SSLCipherSuite ...


6

Do you have an ECDSA certificate?


6

Please don’t get me wrong, but I’m not really sure why the question arises as it should be pretty clear when you’ve checked the manual. Quoting the information available online at https://www.openssl.org/docs/manmaster/apps/enc.html … aes-[128|192|256]-cfb = 128/192/256 bit AES in 128 bit CFB mode aes-[128|192|256]-cfb1 = 128/192/256 bit AES in 1 bit CFB ...


5

Bare keys do not have "key IDs". They're just series of numbers. If the key belongs to an X.509 certificate, then the certificate's fingerprint (a SHA-1 hash of the DER-encoded cert) will be used for identification: openssl x509 -outform der | openssl sha1, or openssl x509 -noout -fingerprint. Otherwise (if it's just a bare public/private keypair), the ...


5

openssl rsa -des3 -in server.key -out newserver.key



Only top voted, non community-wiki answers of a minimum length are eligible