Use openssl tools for SSL Fault Analysis

Source: Internet
Author: User
Article Title: Use openssl to analyze SSL faults. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Currently, the SSL protocol is widely used. How can I quickly find out the root cause of the problem when the SSL server's Identity Authentication fails? This document, combined with the command line tool s_client provided by openssl, lists various authentication failures and provides troubleshooting methods.
SSL handshake protocol

First, we will briefly introduce the SSL connection process. As shown in 1, the main process is as follows:

Figure 1. SSL authentication and key negotiation process

● The client initiates a request, including a hello message, and attaches the password algorithm supported by the client, the version message of the SSL protocol, and the random number used to generate the key.
● After the server receives the message, the server selects the encryption and compression algorithm and generates a random number from the server to send the message back to the client; then, the server sends its digital certificate (an X.509 digital certificate is used in Figure 1) to the client. After the preceding operation is completed, the server sends a "hello done" message to the client. In addition, if the server needs to authenticate the client, the server also sends a message requesting the client certificate.
● Once the client receives "hello done", it is feasible to authenticate the server's digital certificate and check the algorithm selected on the server. If the server requires client authentication, the client also sends its own public key certificate.
● If the server authentication succeeds, the client initiates a key exchange request.
● The server and client generate symmetric keys based on previously negotiated algorithms and exchanged random numbers for subsequent communication.

S_client Introduction

Openssl provides an open-source implementation of the SSL protocol, which includes three parts: the ssl library, the encryption/Decryption library, and the command line tool. In the command line tool, s_client is a client program that connects to a remote server using the SSL protocol. This tool can be used for testing and diagnosis. Although s_client only provides some basic functions, most interfaces of the ssl library are used in its internal implementation.

S_client command line Syntax:

Listing 1. s_client Parameters

openssl s_client [-connect host:port>] [-verify depth] [-cert filename] [-key filename]  [-CApath directory] [-CAfile filename][-reconnect] [-pause] [-showcerts] [-debug] [-msg]  [-nbio_test] [-state] [-nbio] [-crlf] [-ign_eof] [-quiet]

Common parameters are used as follows:

●-Connect host: port: Specifies the address and port of the remote server. If this parameter is not set, the default value is localhost: 443;
●-Cert filename: if the server needs to verify the identity of the client, use-cert to specify the Certificate file of the client.
●-Key filename: Specifies the private key file;
●-Verify depth: Enable server certificate verification and define the maximum depth of the certificate verification process.
●-Showcerts: displays the server certificate chain;
●-CAfile filename: Specifies the root certificate used to verify the server certificate;
●-State: print the SSL session status.

[1] [2] [3] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.