Tag: openssl

  • CentOS Error checking for OpenSSL library … not found

    CentOS Error checking for OpenSSL library … not found

    When installing Nginx from source on a CentOS 7 server, I got the following error

    checking for OpenSSL library ... not found
    checking for OpenSSL library in /usr/local/ ... not found
    checking for OpenSSL library in /usr/pkg/ ... not found
    checking for OpenSSL library in /opt/local/ ... not found
    

    To fix the error, install openssl-devel package with the command

    yum install openssl-devel -y
    

    Back to Errors

  • PHP Script to verify private key matches SSL certificate?

    OpenSSL command can be used to verify if an SSL certificate matches a private key file. You need to find the checksum for the SSL certificate and Private key, if both checksums are the same, then the key matches.

    To make this process easier, I created a PHP script to verify if the SSL certificate matches the private key provided.

    Create a file

    mkdir ~/bin/
    vi ~/bin/ssl-verify
    

    Add following content

    #!/usr/bin/php
    
    

    Make it executable

    chmod 755 ~/bin/ssl-verify
    

    To verify an SSL and key file, go to the folder where the SSL certificate and key file are present, then run the command

    ssl-verify
    
  • Encrypting a file using OpenSSL

    To encrypt a file, run

    openssl enc -aes-256-cbc -in FILE -out FILE.enc
    

    To decrypt, use

    openssl enc -d -aes-256-cbc -in FILE.enc -out FILE
    

    You can use -k option to provide password in commend line itself so it won’t prompt for password.

    Here is a script i use to take backup

    boby@hon-pc-01:~$ cat ~/bin/backup-my-files 
    #!/bin/bash
    
    cd $HOME/work/
    rm -f myfiles.tar.gz myfiles.tar.gz.openssl
    tar --exclude='MY_FILES/.git' -zcvf myfiles.tar.gz MY_FILES
    openssl enc -aes-256-cbc -in /home/boby/work/myfiles.tar.gz -out myfiles.tar.gz.openssl
    
    echo "Backup available in folder $HOME/work"
    echo "You can decrypt file using"
    echo ""
    echo "openssl enc -d -aes-256-cbc -in myfiles.tar.gz.openssl -out myfiles.tar.gz"
    
    boby@hon-pc-01:~$ 
    

    openssl

    Encrypt

  • openssl

    View SSL certificate details

    openssl x509 -in ssl.crt -text -noout
    

    To get SSL certificate details of a web site

    timeout 5 echo QUIT | openssl s_client -connect serverok.in:443 2>&1 | openssl x509 -noout -text