Здесь показаны различия между двумя версиями данной страницы.
Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
howto:utils:openssl [2022/07/18 12:13] Алексей Кожевников |
howto:utils:openssl [2023/05/17 15:42] (текущий) Алексей Кожевников |
||
---|---|---|---|
Строка 3: | Строка 3: | ||
===== Информация о сертификате ===== | ===== Информация о сертификате ===== | ||
- | <code|Вся информация>openssl x509 -in cert.pem -text -noout</code> | + | информация |
+ | |||
+ | <code> | ||
+ | openssl x509 -in cert.pem -text -noout | ||
+ | </code> | ||
Даты | Даты | ||
- | <code>openssl x509 -in cert.pem -dates -noout</code> | + | |
+ | <code> | ||
+ | openssl x509 -in cert.pem -dates -noout | ||
+ | </code> | ||
Дата окончания | Дата окончания | ||
- | <code>openssl x509 -in cert.pem -enddate-noout</code> | + | |
+ | <code> | ||
+ | openssl x509 -in cert.pem -enddate-noout | ||
+ | </code> | ||
===== Генерация самоподписанного сертификата ===== | ===== Генерация самоподписанного сертификата ===== | ||
+ | |||
<code> | <code> | ||
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout selfsigned.key -out selfsigned.crt | openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout selfsigned.key -out selfsigned.crt | ||
</code> | </code> | ||
+ | |||
===== Конвертация DER (.crt .cer .der) в PEM ===== | ===== Конвертация DER (.crt .cer .der) в PEM ===== | ||
+ | |||
<code> | <code> | ||
openssl x509 -inform der -in certificate.cer -out certificate.pem | openssl x509 -inform der -in certificate.cer -out certificate.pem | ||
</code> | </code> | ||
+ | |||
===== Конвертация x509 в pfx ===== | ===== Конвертация x509 в pfx ===== | ||
+ | |||
<code> | <code> | ||
openssl pkcs12 -export -out selfsigned.pfx -inkey selfsigned.key -in selfsigned.crt | openssl pkcs12 -export -out selfsigned.pfx -inkey selfsigned.key -in selfsigned.crt | ||
</code> | </code> | ||
+ | |||
===== Конвертация pfx в отдельные файлы .crt и .key ===== | ===== Конвертация pfx в отдельные файлы .crt и .key ===== | ||
Экстрагируем сертификат: | Экстрагируем сертификат: | ||
- | <code>openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]</code> | + | |
+ | <code> | ||
+ | openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt] | ||
+ | </code> | ||
Получаем RSA ключ с паролем | Получаем RSA ключ с паролем | ||
- | <code>openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]</code> | + | |
+ | <code> | ||
+ | openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key] | ||
+ | </code> | ||
Получаем RSA ключ без пароля: | Получаем RSA ключ без пароля: | ||
- | <code>openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]</code> | + | |
- | Получаем PEM ключ: | + | <code> |
- | <code>openssl rsa -in [keyfile-encrypted.key] -outform PEM -out [keyfile-encrypted-pem.key]</code> | + | openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key] |
+ | </code> | ||
===== Проверка HTTPS ===== | ===== Проверка HTTPS ===== | ||
+ | |||
<code> | <code> | ||
echo | openssl s_client -connect [ip-or-host]:443 -servername [host] 2>/dev/null | openssl x509 -noout -enddate | echo | openssl s_client -connect [ip-or-host]:443 -servername [host] 2>/dev/null | openssl x509 -noout -enddate | ||
Строка 39: | Строка 68: | ||
===== Проверка SMTP ===== | ===== Проверка SMTP ===== | ||
- | <code> openssl s_client -connect [ip-or-host]:25 -CAfile CA-cert.pem -starttls smtp | openssl x509 -enddate -noout</code> | + | <code> |
+ | openssl s_client -connect [ip-or-host]:25 -CAfile CA-cert.pem -starttls smtp | openssl x509 -enddate -noout | ||
+ | </code> | ||
{{tag> openssl }} | {{tag> openssl }} | ||
+ | |||
+ |