What is the difference between .CER and .CRT? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago .
Is there a difference between .cer and .crt. I know they both are same SSL certificate format, but don’t know what is the difference between them. If there no difference, why 2 different extensions?
asked Jan 28, 2020 at 20:54
858 2 2 gold badges 8 8 silver badges 22 22 bronze badges
Jan 28, 2020 at 21:15
Apr 20, 2020 at 18:13
2 Answers 2
Extensions are useless, as are filenames. They DO NOT count. Only the content counts. The software does not care how you call your filenames, holding certificates and private keys, it could be foobar.42 and would work as well (as long as the content is correct).
The names are only to aid the humans to more easily know what it is about. It is customary for example to use the site name as filename to clearly identify it, and then use «some» extension, on one side for a certificate ( .cert or .crt or .cer ) and a private key ( .key ). You also have certificate signing requests (something you generate before getting the certificate), which are often .csr .
You may find .pem sometimes also, which is ambiguous: PEM is a format to encode a content, you can encode a certificate or a key, so just by .pem you do not know what it is about where .crt vs .key at least make the difference clear.
Now, .cert would probably be the most obvious choice. but since we inherit from some past arbitrary limits of some past OS, we often prefer 3 letters for extensions, at most, so pick your poison between shortening .cert either to .cer or .crt (the latter seems to me more often found). Also for the same silly past arbitrary decisions, some OS attaches specific actions on specific files based on their name. Your OS may treat the same file differently if it ends in .crt vs ending in .cer . But this is all configuration and local preferences, again only the content really matters.
answered Jan 28, 2020 at 21:41
Patrick Mevzek Patrick Mevzek
11.4k 16 16 gold badges 39 39 silver badges 54 54 bronze badges
In a good world, where everyone can be trusted, we might not need encryption, identification, certificates and such. But such world does not exist unfortunately, bad guys are everywhere, and thus came along the need for encryption, and symmetric keys were born. 1 key that is the same for both the client and the server to encrypt & decrypt the data is all that is needed. The process is fast, as the key is usually 256 bits in length only. All good.
One concern though is, how do we distribute the key securely?
Born was the public key infrastructure system, PKI or PKIX(X for X.509), where the public key is distributed to encrypt, and the private key,(not distributed, therefore secure), to decrypt. These are called asymmetric keys, which are usually at least 2048 bits, more robust, but you guess well, slower.
Then we needed a standard to construct those keys, X.500 came along, and evolved into X.509 v3 which is encoded in either .DER(binary) or .PEM(which is just a base-64 encoding of the DER, enclosed between «——BEGIN CERTIFICATE——» and «——END CERTIFICATE——). So, sometimes, you might see .DER, sometimes .PEM certificates.
Together with .DER and .PEM, we also have other related certificates formats such as .CER and .CRT.
The difference, a good explanation taken from here:
.CRT = The CRT extension is used for certificates. The certificates may be encoded as binary DER or as ASCII PEM. The CER and CRT extensions are nearly synonymous. Most common among *nix systems
CER = alternate form of .crt (Microsoft Convention) You can use MS to convert .crt to .cer (.both DER encoded .cer, or base64[PEM] encoded .cer) The .cer file extension is also recognized by IE as a command to run a MS cryptoAPI command
Hopefully, the above has given you a background and some idea of the oh-so-many certificate extensions lying around and which can be quite confusing at times, especially for the new comer.
How to convert .crt cetificate file to .pfx
I want to install the ‘.crt’ certificate I received from a certificate provider to my IIS 7.5 server. I have tried many times to install the .crt file by clicking on the ‘certificates’, and it states that it is installed correctly. So I open IIS, select «my server», open «server certificate» which is available on the menu on the right side, click «complete certificate request», select the .crt certificate on my computer and click ok. However, when I refresh IIS the certificate disappears automatically. Our hosting provider mentions that I need to use a ‘.pfx’ file which I do not have.
23.7k 4 4 gold badges 27 27 silver badges 46 46 bronze badges
asked Apr 2, 2012 at 5:52
mayur Rathod mayur Rathod
1,224 1 1 gold badge 12 12 silver badges 26 26 bronze badges
4 Answers 4
I have solved this issue by converting this .crt file into a .pfx file using following method.
To convert .crt to .pfx , we need CSA certificate (Private Key) provided by hosting provider. Below are the steps to convert this:
- Download and install OpenSSL software from below link based on your system type https://slproweb.com/products/Win32OpenSSL.html
- Run the following command on command prompt:
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt OR openssl pkcs12 -export -out certificate.pfx -inkey privateKey.txt -in certificate.crt -certfile CACert.crt
Certificate.crt = Your-domain-Name.crt
CACert.crt = NetworkSolutions_CA.crt
certificate.pfx is the new name of generated file.
PrivateKey can be in .key or .txt format
After completing this process now we have certificate.pfx file so go to IIS Server certificates in IIS Manager.
There is an import link button on right side, click on this and select the converted certificate and enter password which is enter at the time of creation of the .pfx file and complete the process.
Now select your site on IIS and right click on this, select «Edit Binding» and on the new popup window select type as https:// and «Hosting name» is your domain name and all other field is as it is, click on ok to complete this process.
Now restart IIS and your certificate is working fine with your site.
Convert .crt file to .cer and .key
I was asked to help converting a certificate for a renewal. I was given the domainname.crt file along with some intermediate .crt files, but no .key file. They want me to convert the CRT to both a .CER and a .KEY file. I have looked at the following (among many other sites) but they either say I need the .key file, which I don’t have, or that I have to install it locally and then export it, but when using MMC and trying to export it the .PFX option is grayed out. http://community.spiceworks.com/topic/367133-i-cant-convert-a-ssl-crt-to-pfx-i-need-help-with-this I also tried the OpenSSL command PKCS12 -EXPORT. to convert it to a .P12 and I get an error for «unable to load private key». If I open it and choose «Copy To File. » I can obtain a .CER file but nothing more. Thank you for your help.
asked Aug 14, 2014 at 23:10
user1970778 user1970778
361 2 2 gold badges 5 5 silver badges 10 10 bronze badges
This question is off-topic as it’s not programming-related.
Aug 15, 2014 at 7:44
2 Answers 2
Is the private key in the certificate file? In other words, in there a section that starts with
-----BEGIN RSA PRIVATE KEY-----
If not, then the private key is stored in a separate file.
In any case, to renew a certificate, you don’t need a certificate, but a certificate signing request (CSR), which you will send to the CA, and you will receive the certificate in return (alternatively, in some cases the CA may generate a new certificate using the previous stored CSR).
You can generate a new key with:
openssl genrsa -out 2048
then generate the CSR with:
openssl req -new -key -out
You keep the key, send the CSR to the CA. On return, you get the certificate, which together with the intermediate certificates and the private key, should be provided to the software used. In some cases they need to be in separate files, in others you can just lump them up together in a single file.
Нужно ли мне конвертировать .CER в .CRT для сертификатов SSL Apache? Если да, то как?
У меня есть файл * .key, но вся документация, которую я нашел в Интернете, указаны файлы * .crt, а мой центр сертификации предоставил мне только файл * .cer.
Файлы * .cer — это то же самое, что * .crt? Если нет, как я могу преобразовать CER в формат CRT?
CER а CRT расширения ничего не значат. Разные поставщики PKI используют разные расширения для одного и того же. Если файл двоичный, то, вероятно, он закодирован в ASN.1 / DER. Если файл доступен для чтения человеком ——BEGIN CERTIFICATE—— , то его кодировка PEM. Что у вас есть (DER или PEM) и что вам нужно (DER или PEM)?
Расширения файлов для криптографических сертификатов на самом деле не так стандартизированы, как можно было бы ожидать. Windows по умолчанию обрабатывает двойной щелчок по .crt файлу как запрос на импорт сертификата в хранилище корневых сертификатов Windows, но обрабатывает .cer файл как запрос только на просмотр сертификата. Итак, они разные в том смысле, что Windows имеет различное значение для того, что происходит, когда вы дважды щелкаете каждый тип файла.
Но то, как Windows обрабатывает их, когда вы дважды щелкаете по ним, — это почти единственная разница между ними. Оба расширения просто представляют, что они содержат публичный сертификат. Вы можете переименовать файл сертификата, чтобы использовать одно расширение вместо другого в любой системе или файле конфигурации, который я видел. А на платформах, отличных от Windows (и даже в Windows), люди не особо заботятся о том, какое расширение они используют, и рассматривают их как взаимозаменяемые, поскольку между ними нет разницы, если содержимое файла правильное.
Еще больше сбивает с толку то, что существует два стандартных способа хранения данных сертификата в файле: один — «двоичная» кодировка X.509, а другой — «текстовая» кодировка base64, которая обычно начинается с « ——BEGIN CERTIFICATE—— ». Они кодируют одни и те же данные, но по-разному. Большинство систем принимают оба формата, но при необходимости вы можете преобразовать один в другой с помощью openssl или других инструментов. Кодировка в файле сертификата действительно не зависит от того, какое расширение кто-то дал файлу.
Насколько я понимаю, это обе кодировки X.509. Вы не говорите иначе, но асимметричное использование x.509 выше может подсказать читателю иное. Читателю стоит отметить, что сертификаты можно преобразовывать туда и обратно между этими двумя кодировками, потому что, как упоминается в этом ответе, они содержат одинаковую информацию. См. Другой ответ с помощью команд openssl x509 -inform.
SSLCertificateFile: Name: SSLCertificateFile Description: Server PEM-encoded X.509 certificate file
Файл сертификата должен быть файлом сертификата X.509 в кодировке PEM:
openssl x509 -inform DER -in certificate.cer -out certificate.pem
Решит ли это ошибки сертификатов ssl, если они zscaler работают vagrant на win ( vbox homestead ), установив наши доверенные корневые сертификаты в бродячий ящик? Я использовал scp их, затем использовал ваше преобразование и связал их с ними, /etc/ssl/certs а также скопировал содержимое в ca-certificates.crt файл перед повторной инициализацией, и все равно я получаю сообщение google-recaptcha tls ssl об ошибке file_get_contents в окне разработчика.
В основном существует два типа кодировки сертификатов CER: DER и Base64. Когда тип DER возвращает сертификат загрузки с ошибкой (процедуры кодирования asn1), попробуйте PEM, и он должен работать.
openssl x509 -inform DER -in certificate.cer -out certificate.crt
openssl x509 -inform PEM -in certificate.cer -out certificate.crt
Формат DER работал у меня, когда мой файл cer выглядел как двоичный, когда я пытался его отредактировать . спасибо!
Для читателя я нашел справочную страницу openssl полезной. Мне было непонятно, какая из команд что делает (т.е. в каком направлении происходит преобразование). Параметр -inform указывает формат входного файла -in, который интуитивно понятен, но если вы уже немного запутались, неплохо знать явно. См openssl.org/docs/manmaster/man1/openssl-x509.html
Я предполагаю, что у вас есть файл .cer, содержащий данные сертификата в кодировке PKCS # 7, и вы хотите преобразовать его в данные сертификата в кодировке PEM (обычно файл .crt или .pem). Например, файл .cer, содержащий данные в кодировке PKCS # 7, выглядит так:
----- НАЧАТЬ PKCS7 ----- MIIW4gYJKoZIhvcNAQcCoIIW0zCCFs8CAQExADALBgkqhkiG9w0BBwGggha1MIIH . POI9n9cd2cNgQ4xYDiKWL2KjLB + 6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G + bKhADEA ----- КОНЕЦ PKCS7 -----
Данные сертификата PEM выглядят так:
----- НАЧАТЬ СЕРТИФИКАТ ----- MIIHNjCCBh6gAwIBAgIQAlBxtqKazsxUSR9QdWWxaDANBgkqhkiG9w0BAQUFADBm . nv72c / OV4nlyrvBLPoaS5JFUJvFUG8RfAEY = ----- КОНЕЦ СЕРТИФИКАТА -----
Существует команда OpenSSL, которая преобразует файлы .cer (с данными PKCS # 7) в данные PEM, которые вы, возможно, ожидаете встретить ( BEGIN CERTIFICATE блок в приведенном выше примере). Вы можете принудительно преобразовать данные PKCS # 7 в формат PEM с помощью этой команды в файле, который мы назовем certfile.cer:
openssl pkcs7 -text -in certfile.cer -print_certs -outform PEM -out certfile.pem
Обратите внимание, что файл .cer или .pem может содержать один или несколько сертификатов (возможно, всю цепочку сертификатов).
Было бы удобно, если бы у вас был источник этого предположения. Я думаю, что люди используют (возможно, неправильно) .cer, .crt, .pem взаимозаменяемо), поэтому наличие источника правды исправит неправильные представления.
CER — это сертификат X.509 в двоичной форме в кодировке DER .
CRT — это двоичный сертификат X.509, заключенный в текстовую ( base-64 ) кодировку.
Это не та кодировка.
Это неверный ответ. И .CER, и .CRT могут использовать кодировку DER или PEM (текст). Расширения .pem и .der отражают кодировку, а .cer и .crt — нет. Подробнее .
На самом деле должно быть наоборот. Но все эти расширения путали давно, поэтому полагаться на них не стоит.
Ответ на вопрос, как преобразовать файл .cer в файл .crt (они кодируются по-разному!):
openssl pkcs7 -print_certs -in certificate.cer -out certificate.crt
Это не сработало для меня! Я использовал: openssl x509 -inform der -in certificate.cer -out certificate.pem