Curl php ssl certificate problem certificate has expired

Curl SSL error certificate has expired

Traceback (most recent call last): File "grafana-utils.py", line 95, in grafana_backup_all() File "/home/trobz/.local/lib/python2.7/site-packages/click/core.py", line 700, in __call__ return self.main(*args, **kwargs) File "/home/trobz/.local/lib/python2.7/site-packages/click/core.py", line 680, in main rv = self.invoke(ctx) File "/home/trobz/.local/lib/python2.7/site-packages/click/core.py", line 873, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/trobz/.local/lib/python2.7/site-packages/click/core.py", line 508, in invoke return callback(*args, **kwargs) File "grafana-utils.py", line 56, in grafana_backup_all data = json.loads(api_grafana_get_data(host, key)) File "grafana-utils.py", line 15, in api_grafana_get_data data = requests.get( host + '/api/search', headers=key).text File "/home/trobz/.local/lib/python2.7/site-packages/requests/api.py", line 72, in get return request('get', url, params=params, **kwargs) File "/home/trobz/.local/lib/python2.7/site-packages/requests/api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "/home/trobz/.local/lib/python2.7/site-packages/requests/sessions.py", line 512, in request resp = self.send(prep, **send_kwargs) File "/home/trobz/.local/lib/python2.7/site-packages/requests/sessions.py", line 622, in send r = adapter.send(request, **kwargs) File "/home/trobz/.local/lib/python2.7/site-packages/requests/adapters.py", line 511, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='grafana.trobz.com', port=443): Max retries exceeded with url: /api/search (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)) 
curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above. 

I have a look https://curl.haxx.se/docs/sslcerts.html but still don’t understand how to solve this issue.

No client certificate CA names sent Peer signing digest: SHA512 Server Temp Key: X25519, 253 bits --- SSL handshake has read 3208 bytes and written 295 bytes Verification error: certificate has expired --- New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384 Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : ECDHE-RSA-AES256-GCM-SHA384 Session-ID: D84D38798779A0009ED548D3C05188D46793E9BCEF4F79DA65C47CF27110282F Session-ID-ctx: Master-Key: 5F60F42E744D123FB51B271E347C9B6690F4E13D4A0D2634D9468B427D5A6C2A6D6DCB855BE2561EF34477A40190890B PSK identity: None PSK identity hint: None SRP username: None Start Time: 1541057942 Timeout : 7200 (sec) Verify return code: 10 (certificate has expired) Extended master secret: yes --- closed 

I don’t understand this issue only happen with this machine, on my localmachine it work will to connect to the host. Some people tell me curl -k host but I don’t like that because insecure. One more thing, I’m sure the server is OK. so the problem look like from the machine. Server here:

Resolves to grafana.trobz.com Expiration date Dec 31, 2018 Vendor signed Yes Hostname Matches Key length 2048 Server type nginx Common name *.trobz.com SAN *.trobz.com, trobz.com Organization Let's Encrypt Common name Let's Encrypt Authority X3 Let's Encrypt Authority X3 Serial number 03:1b:2d:bb:65:5d:b4:b2:70:c3:18:45:0a:ea:db:05:62:48 Signature algorithm sha256WithRSAEncryption Fingerprint (SHA-1) A35C6987779070AB273471A0E2FA55AB87621822 Fingerprint (MD5) A4BBF42BED757F638CB273095102E807 

Источник

Читайте также:  Link css asp net

Перестали работать запросы в WordPress: cURL error 60: SSL certificate has expired

C 30 сентября 2021 года на сайтах WordPress, для которых был установлен сертификат Let’s Encrypt, могут перестать работать HTTP API запросы. Например такой запрос будет выдавать ошибку:

$res = wp_remote_get( 'https://wp-kama.ru/' ); if( is_wp_error( $res ) )< echo $res->get_error_message(); >
  • в админке при проверке обновлений WordPress
  • при проверке обновлений плагинов
  • при обращении к апи любого сервиса. Например, перестанет работать плагин TinyPNG — JPEG, PNG & WebP image compression и куча других, которые используют какие бы то ни было запросы.

Почему мы видим ошибку certificate has expired?

Почему так происходит подробно расписано на хабре.

Если коротко, то в ядре WP есть файл корневых сертификатов /wp-includes/certificates/ca-bundle.crt который используется для проверки SSL всех запросов созданных через HTTP API. В этом файле просрочен один из корневых сертификатов на основе которого был создан сертификат для вашего сайта. Поэтому запрос не может пройти проверку и выдается такая ошибка.

С очередными обновлениями WP эта ошибка должна пропасть, но вот что делать если решение нужно уже сегодня, или если вы не планируете обновлять WordPress, а рабочие HTTP запросы нужны.

Решение ошибки: cURL error 60: SSL certificate has expired

Вариант 1

Нужно обновить контент файла /wp-includes/certificates/ca-bundle.crt изменить его на контент этого файла https://curl.haxx.se/ca/cacert.pem.

Изменять в данном случае файл ядра допустимо, потому что при следующем обновлении WP проблема исчезнет. См. соответствующий коммит на GitHub.

Это можно сделать вручную:

  1. Скачайте файл по ссылке https://curl.haxx.se/ca/cacert.pem.
  2. Обновите контент /wp-includes/certificates/ca-bundle.crt контентом из скаченного файла.

Или используйте следующий код

Использовать код удобно, когда у вас есть возможность запустить код из админки или как-то еще, например через плагин Code Snippets.

Добавьте следующий код куда угодно и перейдите на страницу http://ВАШСАЙТ.com/?update-wp-ca-bundle .

/** * Goto http://yoursite.com/?update-wp-ca-bundle */ if( isset( $_GET['update-wp-ca-bundle'] ) ) < $crt_file = ABSPATH . WPINC . '/certificates/ca-bundle.crt'; $new_crt_url = 'https://curl.haxx.se/ca/cacert.pem'; if( is_writable( $crt_file ) )< $new_str = file_get_contents( $new_crt_url ); if( $new_str && strpos( $new_str, 'Bundle of CA Root Certificates' ) )< $up = file_put_contents( $crt_file, $new_str ); echo $up ? 'OK: ca-bundle.crt updated' : 'ERROR: can`t put data to ca-bundle.crt'; >else < echo 'ERROR: cant download https://curl.haxx.se/ca/cacert.pem'; >> else < echo 'ERROR: ca-bundle.crt not writable'; >exit; >

После использования, код нужно удалить.

Вариант 2

Решить проблему можно через хук http_request_args. Этот хук нужно использовать в MU плагине.

  1. Создайте файл loader.php в папке wp-content/mu-plugins (если такой папки у вас нет, создайте её).
  2. Добавьте следующий код в этот файл:

Должна получится такая структура:

Готово! Теперь все должно работать как и прежде.

Источник

How to Fix the WordPress Error 60: SSL certificate problem: certificate has expired

From September 30, 2021, HTTP API requests may stop working on WordPress sites that have a Let’s Encrypt certificate installed. For example, a request like this will result in an error:

$res = wp_remote_get( 'https://wp-kama.com/' ); if( is_wp_error( $res ) )< echo $res->get_error_message(); >
  • In the admin panel when checking for WordPress updates.
  • When checking for plugin updates.
  • When accessing the api of any service. For example, will stop working plugin TinyPNG — JPEG, PNG & WebP image compression and a bunch of others that use any kind of requests.

Why do we see the error certificate has expired?

In brief, WP core has a file of root certificates /wp-includes/certificates/ca-bundle.crt which is used to check SSL of all requests created through HTTP API. In this file one of the root certificates has expired which was used to create a certificate for your site. Therefore, the request can not pass verification and generates this error.

More detailed explanation:

Without going into too much detail, a couple of words for non-specialists as to why the expiration of a DST Root CA X3 certificate will affect certificates issued by Let’s Encrypt. Each system that validates a certificate has its own repository of trusted root certificates. The system will trust certificates that are signed using the private key of one of these root certificates during validation. Root certificates themselves normally have long expiration dates, are seldom changed and are not used when generating end subject certificates (in this case domain name certificates), instead a public key infrastructure implies using chains of trust — root certificates are used to sign intermediate certificates and already using them to sign end subject certificates (domain certificates). Furthermore, in order for a system to trust an end subject certificate, it must be able to trace the full chain from this certificate to one of the root certificates it trusts.

When Let’s Encrypt appeared, its ISRG Root X1 root certificate (like any new root certificate) could not quickly find its way into the trusted certificate stores of a significant number of systems. At the same time, for the successful functioning of the project the issued certificates from the very beginning had to be trusted by the maximum number of systems «out of the box» (without any additional actions from the users of these systems). In this regard, for certificates Let’s Encrypt began to use the chain of trust leading to the root certificate DST Root CA X3 , which is recognized by most systems.

With the next WP update this error disappear, but here’s what to do if you need the solution today, or if you do not plan to update WordPress, but need working HTTP requests.

Solution: cURL error 60: SSL certificate has expired

You need to update the content of /wp-includes/certificates/ca-bundle.crt file. You need to change it to the content of the https://curl.se/ca/cacert.pem file.

Changing the core file in this case is acceptable, because the next time you update WP, the problem will go away. See corresponding commit on GitHub.

It can be done manually

  1. Download this file https://curl.se/ca/cacert.pem.
  2. Update content of /wp-includes/certificates/ca-bundle.crt with content from the downloaded file.
  3. DONE! Everything should now work as before.

Or use the following code to perform this operation programmatically

Using the code is handy when you have the ability to run the code from the admin panel, for example using Code Snippets plugin.

    Add the following code into the themes functions.php file (or in Code Snippets plugin):

/** * Goto http://yoursite.com/?update-wp-ca-bundle */ if( isset( $_GET['update-wp-ca-bundle'] ) ) < $crt_file = ABSPATH . WPINC . '/certificates/ca-bundle.crt'; $new_crt_url = 'http://curl.haxx.se/ca/cacert.pem'; if( is_writable( $crt_file ) )< $new_str = file_get_contents( $new_crt_url ); if( $new_str && strpos( $new_str, 'Bundle of CA Root Certificates' ) )< $up = file_put_contents( $crt_file, $new_str ); echo $up ? 'OK: ca-bundle.crt updated' : 'ERROR: can`t put data to ca-bundle.crt'; >else < echo 'ERROR: can\'t download curl.haxx.se/ca/cacert.pem'; >> else < echo 'ERROR: ca-bundle.crt not writable'; >exit; >

Источник

Ошибка: «SSL certificate problem: certificate has expired»

Начиная с 1 октября 2021 начал получать много сообщений от пользователей, которые получали ошибку «SSL certificate problem: certificate has expired» при попытке обновить компонент через админку.

Ниже попытаюсь вкратце объяснить, из-за чего возникла проблема и как ее решить.

Причина ошибки:

30 сентября 2021 14:01:15 GMT закончился срок действия корневого сертификата IdenTrust DST Root CA X3.

Из-за этого стала невозможна проверка сертификатов, выпущенным центром сертификации Let’s Encrypt.

Эта проверка осуществляется при отправке запросов с вашего сервера на другой сервер через домен, который имеет SSL-сертификат Let’s Encrypt.

Потому все такие запросы, отправленные через cURL будут выдавать ошибку «SSL certificate problem: certificate has expired«

Исправление:

Если вы получаете эту ошибку при попытке обновить компонент через админку Joomla, то Вам необходимо удалить просроченный сертификат из цепочки сертификатов, которые использует Joomla.

Для этого через ФТП найдите файл /libraries/src/Http/Transport/cacert.pem (в более ранних версиях Joomla — /libraries/joomla/http/transport/cacert.pem) и скачайте его на свой ПК, чтобы сделать резервную копию.

Откройте файл и найдите строку, содержащую «DST Root CA X3«. удалите ее и все последующий блок (это и есть просроченный сертификат):

Если же в Вашем файле сертификаты не подписаны, то найдите нужный по последним 5 буквам — CNTUQ.

Если же Вы столкнулись с ошибкой «SSL certificate problem: certificate has expired» в другом месте, то напишите в тех. поддержку своего хостинга обращение следующего содержания:

«При попытке отправки запросов через cURL получаю ошибку SSL certificate problem: certificate has expired. Удалите, пожалуйста, просроченный сертификат DST Root CA X3 из цепочки сертификатов, которую использует OpenSSL»

You have no rights to post comments

Источник

Оцените статью