TLS/SSL Certificates — The Private Key
There is already a ton of information out there about this topic. But I noticed that there is no one site that provides exactly what I usually need. Some provide only a specific use-case and miss out on others. I often have to do multiple searches. Although searching Google is fast and hits are often accurate, it can still be an exhausting task. It’s about time I create my own documentation.
There are many ways to create a private key
TLS/SSL Certificates require a private key. It’s the very first thing that is required to produce a certificate.
Create an RSA private key and save it to a file
This will create a private key and save it to a file named privatekey.pem. The size of the created key is 2048 bits.
Sometimes you don’t want to save the private key to a file and instead, you want to display it or send it to the screen. For example, you need to cut-and-paste the key to a website or GUI application. You want to save the step of doing a cat command of the file and avoid the step of removing it because for security reasons, you don’t want it saved on your hard drive.
Create an RSA private key and and display it on the screen
The command above will create a private key and send it to STDOUT.
At some point, you will need to save your private key to a file so that it can be used later. I don’t think anyone can memorize an RSA key. As you can see above, it is composed of characters that look meaningless.
So if you need to save it to a file, clearly, it is not desirable to store it in the clear. It would be like saving a password to a file in clear text.
The solution to this problem is to store the private key in encrypted form. The key (passphrase) to encrypt the RSA key will then be smaller, hence, easier to memorize by a human.
Create an encrypted RSA private key
This command will create a private key and encrypt it. The password or passphrase to encrypt the key will be prompted.
Encryption will be done using the AES-256 algorithm. Other types of algorithm are available. Run openssl genrsa –help to view other types.
By using a passphrase, it will be smaller in size and easier to memorize by a human.
However, although prompting for the passphrase is a secure way of supplying the passphrase, there are times when this is not possible. For example, you need to do this programmatically or there is no human to supply the passphrase.
Create an encrypted private key without prompting for passphrase
Instead of prompting for the passphrase, the passphrase can be supplied in the command line through STDIN of openssl. The passphrase used to encrypt the created key above is the word secret.
This command may not be a good idea to use in practice because the passphrase is displayed in clear text. But this is just a demonstration because even with STDIN, you can still supply the passphrase in a secured way and will not display to the screen or appear in the command in clear text.
For example, you can get the passphrase from a file and then pass the contents to the STDIN of the openssl command.
Instead of a file, you can use a command or application to derive the passphrase or retrieve it from a secured source.
The getpassphrase command will send the passphrase to STDOUT and through the STDIN of openssl.
Supplying the passphrase in this manner provides better security since the passphrase is never displayed on the terminal or is never present in the filesystem.
However, eventually, to use a private key, you’ll need it in unencrypted form.
Decrypt an encrypted RSA private key
This command decrypts an encrypted key stored in privatekey_e.pem file. It will prompt for the passphrase to decrypt the key. If the passphrase is correct, the decrypted key will be displayed (sent to STDOUT).
Decrypt an encrypted RSA private key without prompting for the passphrase
Instead of prompting for the passphrase, you can supply the passphrase through STDIN of openssl. This is achieved by using the -passin stdin option of openssl.
What if when you first created a private key you don’t need it encrypted, but later on decided you want it encrypted?
Encrypt an RSA private key
This command will encrypt the private key stored in privatekey.pem file. It will prompt for the passphrase to use.
Encrypt an RSA private key without prompting for the passphrase
The commands above will encrypt the key in privatekey.pem file using a passphrase supplied through the STDIN of openssl. The output (STDOUT) of the openssl command will be the encrypted key.
To save the encrypted key to a file, redirect the output to a file or use the -out option.
OpenSSL Essentials: Working with SSL Certificates, Private Keys and CSRs
OpenSSL is a versatile command line tool that can be used for a large variety of tasks related to Public Key Infrastructure (PKI) and HTTPS (HTTP over TLS). This cheat sheet style guide provides a quick reference to OpenSSL commands that are useful in common, everyday scenarios. This includes OpenSSL examples for generating private keys, certificate signing requests, and certificate format conversion. It does not cover all of the uses of OpenSSL.
How to Use This Guide:
- If you are not familiar with certificate signing requests (CSRs), read the first section
- Aside from the first section, this guide is in a cheat sheet format: a list of self-contained command line snippets
- Jump to any section that is relevant to the task you are trying to complete (Hint: use the Contents menu or your browser’s Find function)
- Most of the commands are one-liners that have been expanded to multiple lines (using the \ symbol) for clarity
About Certificate Signing Requests (CSRs)
If you would like to obtain an SSL certificate from a commercial certificate authority (CA), you must generate a certificate signing request (CSR). A CSR consists mainly of the public key of a key pair, and some additional information. Both of these components are inserted into the certificate when it is signed.
Whenever you generate a CSR, you will be prompted to provide information regarding the certificate. This information is known as a Distinguished Name (DN). An important field in the DN is the Common Name (CN), which should be the exact Fully Qualified Domain Name (FQDN) of the host that you intend to use the certificate with. It is also possible to skip the interactive prompts when creating a CSR by passing the information via command line or from a file.
The other items in a DN provide additional information about your business or organization. If you are purchasing an SSL certificate from a certificate authority, it is often required that these additional fields, such as “Organization”, accurately reflect your organization’s details.
Here is an example of what the CSR information prompt will look like:
If you want to non-interactively answer the CSR information prompt, you can do so by adding the -subj option to any OpenSSL commands that request CSR information. Here is an example of the option, using the same information displayed in the code block above:
Now that you understand CSRs, feel free to jump around to whichever section of this guide covers your OpenSSL needs.
Generating CSRs
This section covers OpenSSL commands that are related to generating CSRs (and private keys, if they do not already exist). CSRs can be used to request SSL certificates from a certificate authority.
Keep in mind that you may add the CSR information non-interactively with the -subj option, mentioned in the previous section.
Generate a Private Key and a CSR
Use this method if you want to use HTTPS (HTTP over TLS) to secure your Apache HTTP or Nginx web server, and you want to use a Certificate Authority (CA) to issue the SSL certificate. The CSR that is generated can be sent to a CA to request the issuance of a CA-signed SSL certificate. If your CA supports SHA-2, add the -sha256 option to sign the CSR with SHA-2.
This command creates a 2048-bit private key ( domain.key ) and a CSR ( domain.csr ) from scratch:
Answer the CSR information prompt to complete the process.
The -newkey rsa:2048 option specifies that the key should be 2048-bit, generated using the RSA algorithm. The -nodes option specifies that the private key should not be encrypted with a pass phrase. The -new option, which is not included here but implied, indicates that a CSR is being generated.
Generate a CSR from an Existing Private Key
Use this method if you already have a private key that you would like to use to request a certificate from a CA.
This command creates a new CSR ( domain.csr ) based on an existing private key ( domain.key ):
Answer the CSR information prompt to complete the process.
The -key option specifies an existing private key ( domain.key ) that will be used to generate a new CSR. The -new option indicates that a CSR is being generated.
Generate a CSR from an Existing Certificate and Private Key
Use this method if you want to renew an existing certificate but you or your CA do not have the original CSR for some reason. It basically saves you the trouble of re-entering the CSR information, as it extracts that information from the existing certificate.
This command creates a new CSR ( domain.csr ) based on an existing certificate ( domain.crt ) and private key ( domain.key ):
The -x509toreq option specifies that you are using an X509 certificate to make a CSR.
Generating SSL Certificates
If you would like to use an SSL certificate to secure a service but you do not require a CA-signed certificate, a valid (and free) solution is to sign your own certificates.
A common type of certificate that you can issue yourself is a self-signed certificate. A self-signed certificate is a certificate that is signed with its own private key. Self-signed certificates can be used to encrypt data just as well as CA-signed certificates, but your users will be displayed a warning that says that the certificate is not trusted by their computer or browser. Therefore, self-signed certificates should only be used if you do not need to prove your service’s identity to its users (e.g. non-production or non-public servers).
This section covers OpenSSL commands that are related to generating self-signed certificates.
Generate a Self-Signed Certificate
Use this method if you want to use HTTPS (HTTP over TLS) to secure your Apache HTTP or Nginx web server, and you do not require that your certificate is signed by a CA.
This command creates a 2048-bit private key ( domain.key ) and a self-signed certificate ( domain.crt ) from scratch:
Answer the CSR information prompt to complete the process.
The -x509 option tells req to create a self-signed certificate. The -days 365 option specifies that the certificate will be valid for 365 days. A temporary CSR is generated to gather information to associate with the certificate.
Generate a Self-Signed Certificate from an Existing Private Key
Use this method if you already have a private key that you would like to generate a self-signed certificate with it.
This command creates a self-signed certificate ( domain.crt ) from an existing private key ( domain.key ):
Answer the CSR information prompt to complete the process.
The -x509 option tells req to create a self-signed certificate. The -days 365 option specifies that the certificate will be valid for 365 days. The -new option enables the CSR information prompt.
Generate a Self-Signed Certificate from an Existing Private Key and CSR
Use this method if you already have a private key and CSR, and you want to generate a self-signed certificate with them.
This command creates a self-signed certificate ( domain.crt ) from an existing private key ( domain.key ) and ( domain.csr ):
The -days 365 option specifies that the certificate will be valid for 365 days.
View Certificates
Certificate and CSR files are encoded in PEM format, which is not readily human-readable.
This section covers OpenSSL commands that will output the actual entries of PEM-encoded files.
View CSR Entries
This command allows you to view and verify the contents of a CSR ( domain.csr ) in plain text:
View Certificate Entries
This command allows you to view the contents of a certificate ( domain.crt ) in plain text:
Verify a Certificate was Signed by a CA
Use this command to verify that a certificate ( domain.crt ) was signed by a specific CA certificate ( ca.crt ):
Private Keys
This section covers OpenSSL commands that are specific to creating and verifying private keys.
Create a Private Key
Use this command to create a password-protected, 2048-bit private key ( domain.key ):
Enter a password when prompted to complete the process.
Verify a Private Key
Use this command to check that a private key ( domain.key ) is a valid key:
If your private key is encrypted, you will be prompted for its pass phrase. Upon success, the unencrypted key will be output on the terminal.
Verify a Private Key Matches a Certificate and CSR
Use these commands to verify if a private key ( domain.key ) matches a certificate ( domain.crt ) and CSR ( domain.csr ):
If the output of each command is identical there is an extremely high probability that the private key, certificate, and CSR are related.
Encrypt a Private Key
This takes an unencrypted private key ( unencrypted.key ) and outputs an encrypted version of it ( encrypted.key ):
Enter your desired pass phrase, to encrypt the private key with.
Decrypt a Private Key
This takes an encrypted private key ( encrypted.key ) and outputs a decrypted version of it ( decrypted.key ):
Enter the pass phrase for the encrypted key when prompted.
Convert Certificate Formats
All of the certificates that we have been working with have been X.509 certificates that are ASCII PEM encoded. There are a variety of other certificate encoding and container types; some applications prefer certain formats over others. Also, many of these formats can contain multiple items, such as a private key, certificate, and CA certificate, in a single file.
OpenSSL can be used to convert certificates to and from a large variety of these formats. This section will cover a some of the possible conversions.
Convert PEM to DER
Use this command if you want to convert a PEM-encoded certificate ( domain.crt ) to a DER-encoded certificate ( domain.der ), a binary format:
The DER format is typically used with Java.
Convert DER to PEM
Use this command if you want to convert a DER-encoded certificate ( domain.der ) to a PEM-encoded certificate ( domain.crt ):
Convert PEM to PKCS7
Use this command if you want to add PEM certificates ( domain.crt and ca-chain.crt ) to a PKCS7 file ( domain.p7b ):
Note that you can use one or more -certfile options to specify which certificates to add to the PKCS7 file.
PKCS7 files, also known as P7B, are typically used in Java Keystores and Microsoft IIS (Windows). They are ASCII files which can contain certificates and CA certificates.
Convert PKCS7 to PEM
Use this command if you want to convert a PKCS7 file ( domain.p7b ) to a PEM file:
Note that if your PKCS7 file has multiple items in it (e.g. a certificate and a CA intermediate certificate), the PEM file that is created will contain all of the items in it.
Convert PEM to PKCS12
Use this command if you want to take a private key ( domain.key ) and a certificate ( domain.crt ), and combine them into a PKCS12 file ( domain.pfx ):
You will be prompted for export passwords, which you may leave blank. Note that you may add a chain of certificates to the PKCS12 file by concatenating the certificates together in a single PEM file ( domain.crt ) in this case.
PKCS12 files, also known as PFX files, are typically used for importing and exporting certificate chains in Microsoft IIS (Windows).
Convert PKCS12 to PEM
Use this command if you want to convert a PKCS12 file ( domain.pfx ) and convert it to PEM format ( domain.combined.crt ):
Note that if your PKCS12 file has multiple items in it (e.g. a certificate and private key), the PEM file that is created will contain all of the items in it.
OpenSSL Version
The openssl version command can be used to check which version you are running. The version of OpenSSL that you are running, and the options it was compiled with affect the capabilities (and sometimes the command line options) that are available to you.
The following command displays the OpenSSL version that you are running, and all of the options that it was compiled with:
This guide was written using an OpenSSL binary with the following details (the output of the previous command):
Conclusion
That should cover how most people use OpenSSL to work with SSL certs. It has many other uses that were not covered here, so feel free to ask or suggest other uses in the comments.
If you are having issues with any of the commands, be sure to comment (and include your OpenSSL version output).
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Где взять приватный ключ сертификата
We stand with our friends and colleagues in Ukraine. To support Ukraine in their time of need visit this page.
How can I find the Private key for my SSL certificate
If you just got an issued SSL certificate and are having a hard time finding the corresponding Private key, this article can help you to find that one and only key for your certificate.
- What is a Private Key?
- Public key vs Private key
- How do you generate a Private key?
- Can I generate a new Private key for my SSL certificate?
- What does a Private key look like?
- How to retrieve a misplaced Private key
- How to retrieve a Private key on different server platforms
What is a Private Key?
Firstly, let’s dive into basics a little. The design of global public key infrastructure, relying on which modern secure negotiation through SSL/TLS is possible, implies that there is always a pair of unique keys —
Public key vs Private key
How do you generate a Private key?
Can I generate a new Private key for my SSL certificate?
Since a public key with the additional information (i.e., domain name and administrative contact information) must be signed by a trusted Certificate Authority in order to make it applicable and legitimate for securing communication with your server, it wouldn’t make much sense if we could just make up a new Private key for an already validated public key. On the other hand, we must be sure that nobody can create a matching Private key basing on a public key. Thus, modern cryptosystems make such a task almost impossible.
What does a Private key look like?

Nonetheless, in most cases, this code won’t come into your sight while generating the CSR. It is usually created in the background and silently saved in the server’s filesystem. And obviously, during the SSL certificate installation the key should be fetched to the certificate automatically. However, some systems do not have such a kind of behavior or sometimes we need to install the certificate on another server. These are the examples of the cases when we really need to know the exact location of the Private key.
How to retrieve a misplaced Private key
Below you can find tips, examples and pieces of advice that you can consider to follow in order to get a missing puzzle and avoid certificate reissue (i.e., repeating the process of activation and validation from scratch).
How to retrieve a Private key on different server platforms
Linux operating systems (Apache, Nginx, Lighttpd, Heroku)
Traditionally, Private keys on Linux-based operating systems (Ubuntu, Debian, CentOS, RedHat, etc.) are openssl generated keys with the crypto toolkit and saved into files with the .key or .pem extension. However, since specific extensions are not obligatory for simple text files on Linux systems, the Private key code can be put into a file with virtually any name.
If you remember the full or partial name of the .key file, you can try to get its location by running the ‘find’ command as below:
sudo find [search_start_folder] -type f -iname ‘private.key’
— [search_start_folder] parameter indicates the directory to start the search from and through all directories inside it, for example, to search from “root”, the / sign should be specified;
— to do the search by a partial filename, the assumed name of the file should be specified with an asterisk (*), for example, the “*.key” value allows locating every file with the name ending with “.key”.HINT: Very often, the name of the key file resembles the domain name the certificate is issued for, e.g., “example.com.key”, “example_com.key”, “example-com.key” etc.
Another way to get the Private key file location is to search inside the files by certain patterns:
grep -r —exclude-dir=log —exclude-dir=ssh —exclude=*history -I -l -e ‘——BEGIN PRIVATE*’ -e ‘——BEGIN RSA*’ -e ‘——BEGIN EC*’ [search_start_folder] 2> /dev/null
This one-liner command prints out an absolute path to the file, which contains a matching expression (——BEGIN header), for example, “/etc/ssl/private.key”.
Windows operating systems (IIS, Exchange, Small Business server)
Windows systems do not allow retrieving the Private key in plain text. When an SSL certificate is imported either through Microsoft Management Console (MMC) or IIS, the matching Private key is bound to the certificate automatically, of course, if the certificate is being imported to the same instance the key was generated on. But if we need to get the Private key for example for the certificate installation on another server, there is an option to export the key in a password protected file (PFX or PKCS12 format). To do so, you will need to open MMC Certificates snap-in in the following way:
Win+R > mmc.exe > OK > File > Add/Remove Snap-in > Certificates > Add > Computer account > Next > Local computer > Finish > OK
Then navigate to Certificate Enrollment Requests > Certificates (if the certificate request was not completed) or Personal > Certificates (if the certificate request was already completed) folder, right-click on the certificate entry and click All Tasks > Export to open the export wizard. More details on the export process can be found here.

As a result, you will receive a .pfx file containing the key. To get the key in plain text, you can convert the .pfx into PEM-encoded files using tool (PKCS#12 to PEM option).
The default “Keychain” tool in the Server app does not allow accessing the generated Private key through the graphic user interface. However, using the command line tools in Terminal, it is possible to navigate to the “/etc/certificates” folder and open the key file, which should be called something like “.key.pem”.
Tomcat (using keytool)
Unless the SSL connector on Tomcat is configured in APR style, the Private key is usually stored in a password-protected Java keystore file (.jks or .keystore), which was created prior to the CSR. To extract the key in PEM format, the keystore should be converted into .pfx/.p12 (PKCS#12) file firstly. With the ”keytool” utility, it can be done with the help of the following command:
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias -srcstorepass -srckeypass -deststorepass -destkeypass
“keystore.jks” should be replaced with the name of the keystore, containing the required key; “keystore.p12” — with the name of the .pfx/.p12 file the keystore will be converted into; , and refer to the alias, the keystore password and the key password values specified during the keystore generation; and values are required for securing the integrity of the new .pfx./p12 file; it is possible to use the same password for both parameters though.
When the .pfx/.p12 file is created, it can be converted into PEM formatted files either with the help of this tool (PKCS#12 to PEM option) or using OpenSSL. The OpenSSL command would be:
openssl pkcs12 -in keystore.p12 -nocerts -nodes -out private.key
— ‘private.key’ refers to the name of the file the Private key text will be saved to.
There are 2 ways to get to the Private key in cPanel:
-
Using SSL/TLS Manager

There’s another menu in the «SSL/TLS» manager that allows to find the matching Private key for the certificate. Click on «Certificate Signing Request (CSR)» and locate your CSR by the domain.
Scroll the next page down, where you can see the «This CSR uses the following key» option and a link below it to obtain the Private key:


In WHM the Private keys are stored along with the corresponding CSRs and certificates in “SSL Storage manager”. To get there, you can click “SSL/TLS” on the home screen and then on the “SSL Storage manager”. To open the Private key text, you will need to click on the magnifier button in the first column called “Key”.

After navigating to Domains > domain.com > SSL/TLS certificates, you should see the page similar to the one on the screenshot below. The key sign with the message “Private key part supplied” indicates the presence of the needed key in the system. To open it in plain text, you will need to click on the name of the entry and scroll down until the key code appears on the screen. Alternatively, you can click on the green arrow sign on the right and download the .pem file containing the key, the CSR and the certificate along with the CA bundle, if they were imported already. The .pem file can be opened with any text editor like Notepad:

Synology NAS DSM
In Synology DSM, the Private key is downloaded in the archive.zip file on the last step of the CSR generation wizard. It is saved in the server.key file inside the .zip archive and can be opened on a local computer with a text editor:

The Webmin panel was designed as a graphic user interface on top of the command line tools, although it comes with the File manager (Filemin) which can be used for browsing the file system in order to find the key file, which was created by the OpenSSL command in Command Shell when the CSR was generated.

The other way to find the Private key in Webmin is to open “Command shell” under the “Others” section and run the “find” or “grep” command from the “Linux operating systems” paragraph of this article.
The Private key on VestaCP is not saved anywhere throughout the user interface; it is necessary to save the key text into a local file during the CSR generation.
However, there is still a chance to find it through SSH. When VestaCP creates a new CSR, the Private key is stored as a temporary file in the “/tmp” directory. The absolute path to the key file might look like “/tmp/tmp.npAnkmWFcu/example.com.key”, for example. The main bottleneck here is that the files inside “/tmp” are deleted permanently during each server reboot.
To get the location of the key file on your instance, the following command can be invoked:
find /tmp -type f -iname ‘ domain.com .key’
— “domain.com” should be replaced with the actual domain name the CSR was generated for.
Alternatively, the same old “grep” can be used as well:
grep -r -I -l -e ‘——BEGIN PRIVATE*’ -e ‘——BEGIN RSA*’ /tmp 2> /dev/nullDirectAdmin
In the recent versions of DirectAdmin panel the Private key is usually saved in the system and gets pre-fetched in the “Paste a pre-generated certificate and key” section in the SSL Certificates menu.
If during the certificate installation you are about to paste the certificate text under the auto-populated Private key text but see an empty window, it could mean the CSR code was generated elsewhere or the Private key was not added to this window due to a system glitch. In the latter case, it is possible to retrieve the key via SSH. It is normally saved in the following directory: /usr/local/directadmin/data/users/ /domains/ .key , where corresponds to your DirectAdmin username and — to the domain the CSR has been generated for.
The “SSL” section in Webuzo is located on the home page. Clicking on the “Private keys” button will lead to the list of the generated keys. To see the key text, the pencil button should be clicked on the right side of the list under the “Option” column:

The CSR was generated via an online tool
Online tools like decoder.link do not automatically save the generated codes anywhere. So if you create the CSR code and Private key with this kind of tool, you should save them manually in a plain text file. When you’re done, double-check that you have saved both files.
You can check if the file with the Private key is stored with other files on your device. If the file was opened or created recently, it should be shown in the «Recent files» list, which you can find by doing the following:
- Press Windows + E to open File Explorer in a new window;
- Select Quick Access on the left sidebar;
- You will see a list of recently opened files.
- Click Apple Menu;
- Choose the Recent Items option;
- You’ll see the recently opened files in the next window.
I have several Private keys
To complete SSL installation, you should use the Private key that matches the issued SSL certificate. If there are several Private keys in your panel, server, or computer, check which one matches your SSL with this Matcher tool. Follow these steps:
- Open the .crt file via a plain text editor like «Notepad» (for Windows) or «Text Editor» (for Mac);
- Copy the certificate code from the opened file and paste it into the «Certificate» box in the Matcher tool;
- Paste the Private key to the «Private key/CSR» box;
- Click «Match».
More detailed information on how to use this tool can be found here.
Once you find the matching Private key, you can install your SSL.
There is no Private key
In conclusion, if none of the above-mentioned tips were helpful and the original Private key cannot be retrieved, it is necessary to generate the new CSR / Private key pair and reissue the certificate, making sure that the Private key is safe this time.
Где мой Приватный ключ?
Где притаился и прячется pKey ? Как найти мой секретный ключГде мне найти мой Private Key? — общий ответ — Приватный ключ находится рядышком с сертификатом в секретной, специальной, защищенной директории вашего сервера (компьютера) которая обычно называется хранилищем сертификатов.
Что такое private key (pKey) зачем он нужен и с чем его едят?
Для всех SSL-сертификатов для работы требуется закрытый ключ. Закрытый ключ — это отдельный файл, который используется при шифровании / расшифровке данных, отправляемых между вашим сервером и подключающимися клиентами. Закрытый ключ создается вами — владельцем сертификата — когда вы запрашиваете свой сертификат с помощью запроса подписи сертификата (CSR). Центр сертификации, предоставляющий ваш сертификат, не создает и не имеет ваш закрытый ключ. Вы храните ваш Приватный ключ как зеницу ока.
Если вы еще не установили свой сертификат, наиболее вероятное местоположение вашего закрытого ключа находится на компьютере или сервере, на котором вы создали CSR. Когда вы сгенерировали эту CSR, вы бы попросили сервер сохранить два файла — для OpenSSL вы можете запустить команду
Где же находится мой Private Key
Если ваш сертификат уже установлен, выполните следующие действия, чтобы найти файл секретного ключа для этих популярных операционных систем.
Apache
Местоположение вашего личного ключевого файла будет указано в главном файле конфигурации Apache, который называется httpd.conf или apache2.conf. Директива SSLCertificateKeyFile укажет путь на вашем сервере, где хранится ваш ключ.
Nginx
Вы сможете найти местоположение секретного ключа в файле виртуальных хостов вашего сайта. Перейдите к серверному блоку для этого сайта (по умолчанию в каталоге /var/www/). Откройте основной файл конфигурации для сайта и найдите директиву ssl_certificate_key которая предоставит вам путь к файлу для частного ключа (некоторые пользователи имеют отдельный файл конфигурации для своего SSL, например ssl.conf).
Windows (IIS)
На серверах Windows ОС управляет вашими файлами сертификатов для вас в скрытой папке, но вы можете получить закрытый ключ, экспортировав файл «.pfx», содержащий сертификаты и закрытый ключ. Подробнее процедура трансфера описана в разделе Экпорт-Ипорт сертификатов
Где еще может быть мой приватный ключ?
Если вы работаете с сервером, который обеспечивает рабочие соединения HTTPS, то ключ находится где-то на этом сервере или доступен для этого сервера на другом сервере, в противном случае протокол HTTPS работать не будет. Возможно, ваша организация использует специальную настраиваемую конфигурацию. Вы можете попробовать выполнить поиск на вашем сервере файла «.key» или выполнить шаги, по установке нового сертификат, которые должны указать где сохранить частного ключ. На некоторых платформах OpenSSL сохранит файл .key в том же каталоге, откуда была запущена команда -req
Если вы еще не установили сертификат и не можете найти ключ, возможно, он утерян. Если вы создали CSR, но не можете найти файл ключа, проще всего переиздать свой сертификат. Начните с создания нового PrivateKey или CSR , чтобы сохранить закрытый ключ в известном местоположении и соедините сертификат с этим новым ключом.
Частный, секретный, приватный ключ является «ключевым ключом», который расшифровывает зашифрованные данные, отправленные на сервер во время сеанса SSL. Если секретный ключ был скомпрометирован, зашифрованные данные могут быть легко дешифрованы тем, кто получил этот закрытый ключ. Таким образом, жизненно важно, чтобы закрытый ключ оставался защищенным на сервере в любое время. Открытый ключа встроена в файл CSR и отправляется в компанию CA. При одобрении и выдаче сертификата SSL компания Центр сертификации в цифровом виде подписывает открытый ключ и отправляет его вам для установки на сервер в соответствии с вашим закрытым ключом.
Чтобы в общем ответить на вопрос «Где мой закрытый ключ?» — Приватный ключ храниться на сервере или в любом случае доступен серверу. Как управлять частным ключом и где он может быть найден, все зависит от используемого серверного программного обеспечения. Все серверные программные платформы будут управлять ими по-разному, поэтому, пожалуйста, обратитесь к поставщику вашего сервера или в службу поддержки, если вы не можете найти их на своем сервере.
Как найти или восстановить секретный ключ SSL сертификата в среде IIS MicroSoft?
SSL-сертификат установлен, но отсутствует закрытый ключ. Каковы шаги по восстановлению секретного ключа сертификата SSL в среде Microsoft Internet Information Services (IIS)? Сертификаты SSL не включают закрытый ключ. Закрытый ключ находится на сервере, который сгенерировал запрос подписи сертификата (CSR). При правильной установке сертификат сервера будет соответствовать закрытому ключу, как показано ниже.

- Сертификат устанавливается не на том же сервере, на котором сгенерирован запрос CSR.
- Отложенный запрос — CSR был удален из IIS.
- Сертификат был установлен с помощью мастера импорта сертификатов, а не через IIS.
Решение: Чтобы восстановить закрытый ключ, выполните следующие действия.
- Нажмите кнопку Пуск и выберите команду Выполнить .
- Введите mmc и нажмите OK .
- В меню «Файл» выберите « Добавить / удалить оснастку» .
- В появившемся новом окне нажмите « Добавить» .
- Выберите « Сертификаты» и нажмите « Добавить» .
Шаг 2 — Импорт сертификата сервера
-
Разверните дерево сертификатов (локальный компьютер) в левой панели предварительного просмотра.
-
Найдите файл сертификата сервера (например, server.cer) и дважды щелкните его. Откроется диалоговое окно «Сертификат».
Если Windows смог восстановить закрытый ключ, вы увидите следующее сообщение:

Copyright © 1997-2023 adgrafics