본문 바로가기

카테고리 없음

Generate Key And Crt File Apache Openssl



Jul 08, 2019  To generate the CSR code on Apache or Nginx server you can use openssl command line utility. Open up a command line interface and use the following command: openssl req -new -newkey rsa:2048 -nodes -keyout example.key -out example.csr You will be asked to enter the following information that will be incorporated into your certificate request.

SSL is an essential part of creating a secure Apache site. SSL certificates allow you encrypt all the traffic sent to and from your Apache web site to prevent others from viewing all of the traffic. It uses public key cryptography to establish a secure connection. This means that anything encrypted with a public key (the SSL certificate) can only be decrypted with the private key (stored only on the server) and vice versa.

When to Use a Self Signed Certificate

You should never use a self signed certificate on an e-commerce site or any site that transfers valuable personal information like credit cards, social security numbers, etc.

An SSL certificate is necessary for more than just distributing the public key: if it is signed by a trusted third-party, it verifies the identity of the server so clients know they aren’t sending their information (encrypted or not) to the wrong person. So what is a self signed certificate? It is a certificate that is signed by itself rather than a trusted third party. Isn’t that bad? In most cases, yes. You will almost never want to use a self signed certificate on a public Apache server that requires anonymous visitors to connect to your site because they could easily become a victim of a man-in-the-middle attack. However, self signed certificates have their place:

  • Self signed certificates can be used on an Apache development server. There is no need to spend extra cash buying a trusted certificate when you are just developing or testing an application.
  • Self signed certificates can be used on an intranet. When clients only have to go through a local intranet to get to the server, there is virtually no chance of a man-in-the-middle attack.
  • Self signed certificates can be used on personal sites with few visitors. If you have a small personal site that transfers non-critical information, there is very little incentive for someone to attack the connection.

Just keep in mind that visitors will see a warning in their browsers (like the one below) when connecting to an Apache site that uses a self signed certificate until it is permanently stored in their certificate store. You should never use a self signed certificate on an e-commerce site or any site that transfers valuable personal information like credit cards, social security numbers, etc. Just lay down a few dollars on a trusted cheap SSL certificate or a free SSL certificate.

Generate Your Apache Self Signed Certificate

Great! So now you know when to use an Apache self signed certificate and when not to. Now, let’s create one: First, we need to make sure OpenSSL is installed. If you are installing the self signed certificates on Windows, grab the Windows version of OpenSSL (If you get an error when you run the installer, you may need to download the Visual C++ 2008 Redistributables listed on that page first). If you are on another type of server, try running “openssl” on the command line to see if OpenSSL is already installed. If it is not, you will need to download a package or compile it from its source.

Once you have OpenSSL installed, just run this one command to create an Apache self signed certificate:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mysitename.key -out mysitename.crt

You will be prompted to enter your organizational information and a common name. The common name should be the fully qualified domain name for the site you are securing (www.mydomain.com). You can leave the email address, challenge password, and optional company name blank. When the command is finished running, it will create two files: a mysitename.key file and a mysitename.crt self signed certificate file valid for 365 days.

Install Your Self Signed Certificate

Now, you just need to configure your Apache virtual host to use the SSL certificate. If you only have one Apache virtual host to secure and you have an ssl.conf file being loaded, you can just edit that file. Otherwise, you will need to make a copy of the existing non-secure virtual host, paste it below, and change the port from port 80 to 443.

  1. Open your Apache configuration file in a text editor. Depending on your operating system and Apache version, it will be located in different places but you will usually find it at /etc/httpd/httpd.conf. On a Windows machine, you will usually find it at C:Program FilesApacheApache2confhttpd.conf
  2. In most cases, you will find the <VirtualHost> blocks in a separate file in a directory like /etc/httpd/vhosts.d/ or /etc/httpd/sites/. Add the lines in bold below. <VirtualHost 192.168.0.1:443>
    DocumentRoot /var/www/website
    ServerName www.yourdomain.com
    SSLEngine on
    SSLCertificateFile /etc/ssl/crt/mysitename.crt
    SSLCertificateKeyFile /etc/ssl/crt/mysitename.key

    </VirtualHost>
  3. Change the names of the files and paths to match your certificate files. Save the changes and exit the text editor.
  4. Restart your Apache web server using one of the following commands: /usr/local/apache/bin/apachectl startssl
    /usr/local/apache/bin/apachectl restart

Learn more about installing a certificate in Apache.

Check the Apache Self Signed Certificate Installation

If the Apache site is public, you can use our SSL Checker to verify that it is installed correctly (ignoring the warning that it is not trusted because it is self signed). Otherwise, just go to the website in your web browser using https in the address bar (https://www.mysitename.com) and verify that the certificate is being given out by the server by clicking the certificate icon (after clicking through the warnings).

For more information on generating an Apache self signed certificate, see the following links:

Originally posted on Sat Oct 16, 2010

Save

Important: This example is intended to provide general guidance to IT professionals who are experienced with SSL requirements and configuration. The procedure described in this article is just one of many available methods you can use to generate the required files. The process described here should be treated as an example and not as a recommendation.

When you configure Tableau Server to use Secure Sockets Layer (SSL) encryption, this helps ensure that access to the server is secure and that data sent between Tableau Server and Tableau Desktop is protected.

Looking for Tableau Server on Linux? See Example: SSL Certificate - Generate a Key and CSR.

Tableau Server uses Apache, which includes OpenSSL. You can use the OpenSSL toolkit to generate a key file and Certificate Signing Request (CSR) which can then be used to obtain a signed SSL certificate.

Steps to generate a key and CSR

To configure Tableau Server to use SSL, you must have an SSL certificate. To obtain the SSL certificate, complete the steps:

  1. Generate a key file.
  2. Create a Certificate Signing Request (CSR).
  3. Send the CSR to a certificate authority (CA) to obtain an SSL certificate.
  4. Use the key and certificate to configure Tableau Server to use SSL.

You can find additional information on the SSL FAQ page on the Apache Software Foundation website.

Generate Key And Crt File Apache Openssl Password

Configure a certificate for multiple domain names

Generate key and crt file apache openssl download

Tableau Server allows SSL for multiple domains. To set up this environment, you need to modify the OpenSSL configuration file, openssl.conf, and configure a Subject Alternative Name (SAN) certificate on Tableau Server. See For SAN certificates: modify the OpenSSL configuration file below.

Set the OpenSSL configuration environment variable (optional)

To avoid using the -config argument with every use of openssl.exe, you can use the OPENSSL_CONF environment variable to ensure that the correct configuration file is used and all configuration changes made in subsequent procedures in this article produce expected results (for example, you must set the environment variable to add a SAN to your certificate).

Open the Command Prompt as an administrator, and run the following command:

set OPENSSL_CONF=c:Program FilesTableauTableau Serverpackagesapache.<version_code>confopenssl.cnf

Notes:

  • When setting the Open SSL configuration environment variable, do not enclose the file path with quotation marks.

  • If you are using a 32-bit version of Tableau Server on a 64-bit computer, run the set OPENSSL_CONF=c:Program Files (x86)TableauTableau Serverpackagesapache.<version_code>confopenssl.cnf command instead.

Generate a key

Generate

Generate a key file that you will use to generate a certificate signing request.

  1. Open the Command Prompt as an administrator, and navigate to the Apache directory for Tableau Server. For example, run the following command:

    cd C:Program FilesTableauTableau Serverpackagesapache.<version_code>bin

  2. Run the following command to create the key file:

    openssl.exe genrsa -out <yourcertname>.key 4096

    Note: This command uses a 4096-bit length for the key. You should choose a bit length that is at least 2048 bits because communication encrypted with a shorter bit length is less secure. If a value is not provided, 512 bits is used.

Create a certificate signing request to send to a certificate authority

Use the key file you created in the procedure above to generate the certificate signing request (CSR). You send the CSR to a certificate authority (CA) to obtain a signed certificate.

Important: If you want to configure a SAN certificate to use SSL for multiple domains, first complete the steps in For SAN certificates: modify the OpenSSL configuration file below, and then return to here to generate a CSR.

  1. Run the following command to create a certificate signing request (CSR) file:

    openssl.exe req -new -key yourcertname.key -out yourcertname.csr

    If you did not set the OpenSSL configuration environment variable, OPENSSL_CONF, you might see either of the following messages:

    • An error message about the config information being unable to load. In this case, retype the command above with the following parameter: -config ..confopenssl.cnf.

    • A warning that the /usr/local/ssl directory cannot be found. This directory does not exist on Windows, and you can simply ignore this message. The file is created successfully.

    To set an OpenSSL configuration environment variable, see Set the OpenSSL configuration environment variable (optional) section in this article.

  2. When prompted, enter the required information.

    Note: For Common Name, type the Tableau Server name. The Tableau Server name is the URL that will be used to reach the Tableau Server. For example, if you reach Tableau Server by typing tableau.example.com in the address bar of your browser, then tableau.example.com is the common name. If the common name does not resolve to the server name, errors will occur when a browser or Tableau Desktop tries to connect to Tableau Server.

Send the CSR to a certificate authority to obtain an SSL certificate

Send the CSR to a commercial certificate authority (CA) to request the digital certificate. For information, see the Wikipedia article Certificate authority and any related articles that help you decide which CA to use.

Use the key and certificate to configure Tableau Server

When you have both the key and the certificate from the CA, you can configure Tableau Server to use SSL. For the steps, see Configure External SSL.

For SAN certificates: modify the OpenSSL configuration file

Key

In a standard installation of OpenSSL, some features are not enabled by default. To use SSL with multiple domain names, before you generate the CSR, complete these steps to modify the openssl.cnf file.

Generate Crt File

  1. Open Windows Explorer and browse to the Apache conf folder for Tableau Server.

    For example: C:Program FilesTableauTableau Server<version_code>apacheconf

  2. Open openssl.cnf in a text editor, and find the following line: req_extensions = v3_req

    This line might be commented out with a hash sign (#) at the beginning of the line.

    If the line is commented out, uncomment it by removing the # and space characters from the beginning of the line.

  3. Move to the [ v3_req ] section of the file. The first few lines contain the following text:

    # Extensions to add to a certificate request
    basicConstraints = CA:FALSE
    keyUsage = nonRepudiation, digitalSignature, keyEncipherment

    After the keyUsage line, insert the following line:

    subjectAltName = @alt_names

    If you’re creating a self-signed SAN certificate, do the following to give the certificate permission to sign the certificate:

    1. Add the cRLSign and keyCertSign to the keyUsage line so it looks like the following: keyUsage = nonRepudiation, digitalSignature, keyEncipherment, cRLSign, keyCertSign

    2. After the keyUsage line, add the following line: subjectAltName = @alt_names

  4. In the [alt_names] section, provide the domain names you want to use with SSL.

    DNS.1 = [domain1]
    DNS.2 = [domain2]
    DNS.3 = [etc]

    The following image shows the results highlighted, with placeholder text that you would replace with your domain names.

  5. Save and close the file.

  6. Complete the steps in Create a certificate signing request to send to a certificate authority section, above.

Additional information

Openssl Generate Rsa Key Pair

If you prefer to use a different version of OpenSSL, you can download it from Open SSL for Windows.

Openssl Generate Private Key

Thanks for your feedback!There was an error submitting your feedback. Try again or send us a message.