首页 \ 问答 \ 尝试访问HTTPS网址时,如何使用cURL处理证书?(How do I deal with certificates using cURL while trying to access an HTTPS url?)

尝试访问HTTPS网址时,如何使用cURL处理证书?(How do I deal with certificates using cURL while trying to access an HTTPS url?)

我使用curl得到以下错误:

curl: (77) error setting certificate verify locations:
  CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none

如何设置此证书验证位置? 谢谢。


I am getting the following error using curl:

curl: (77) error setting certificate verify locations:
  CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none

How do I set this certificate verify locations? Thanks.


原文:https://stackoverflow.com/questions/3160909
更新时间:2023-09-10 12:09

最满意答案

我认为使用cron或类似的东西会更好。 默认情况下,PHP将在30秒后停止运行任何脚本。 如果您使用的是托管Web提供商,则通常是不可协商的。

我会承认有些人会编写本地运行的“控制台”类型的应用程序(例如通过命令行),但由于你没有说你这样做,我认为我们可以安全地认为这不是案件。

使用cron一种方法是:让用户指定时间间隔并将其存储在数据库中。 然后在某个其他时间间隔(可能每分钟或每5分钟)检查数据库,以查看上次发送电子邮件的时间是否超过请求的时间间隔。 如果是,您将发送另一封电子邮件并更新数据库中的“上次发送”值。

但是让PHP脚本“睡眠”,或者甚至更糟,被锁定在无限循环中,并不能很好地利用系统的资源。


I think you would be better served using cron or something similar. PHP, by default, will stop running any script after 30 seconds. If you're using a hosted web provider, this is often non-negotiable.

I will concede that some people write "console"-type applications that are run locally (e.g. via the command line), but since you didn't say you're doing this, I think we're safe to assume that is not the case.

One way of using cron would be: Have the user specify the time interval and store it in a database. Then at some other interval (perhaps every minute, or every 5 minutes) check the database to see whether the last time you sent an email is longer than the requested interval. If it is, you would send another email and update the "last time sent" value in the database.

But having a PHP script "sleep", or even worse, get locked in an infinite while loop, is not a good use of the system's resources.

相关问答

更多
  • 使用JQuery: function runTimer(seconds, yourUrl) { setTimeout(function() { $.get(yourUrl); }, seconds * 1000; } 运行: runTimer(5, 'http://example.com/action.php'); 但是使用ajax请求无法重定向到其他页面。 对于重定向使用: function runTimerRedirect(seconds, yourUrl) { setTimeo ...
  • 我认为使用cron或类似的东西会更好。 默认情况下,PHP将在30秒后停止运行任何脚本。 如果您使用的是托管Web提供商,则通常是不可协商的。 我会承认有些人会编写本地运行的“控制台”类型的应用程序(例如通过命令行),但由于你没有说你这样做,我认为我们可以安全地认为这不是案件。 使用cron一种方法是:让用户指定时间间隔并将其存储在数据库中。 然后在某个其他时间间隔(可能每分钟或每5分钟)检查数据库,以查看上次发送电子邮件的时间是否超过请求的时间间隔。 如果是,您将发送另一封电子邮件并更新数据库中的“上次发 ...
  • 使用此功能: function timer(elem, starttime, endtime, speed, funktion, count) { if (!endtime) endtime = 0; if (!starttime) starttime = 10; if (!speed) speed = 1; speed = speed * 1000; if ($(elem).html() || $(elem).val()) { if (count = ...
  • 显然,如果你可以使用它们 - cronjobs是正确的解决方案。 但是,如果你只是有一个小网站空间或某些你无法设置cronjobs的东西,你需要别的东西。 你当然可以在php中这样做,但这很好,因为你不能保证它在指定的时间运行,也许它会在很晚以后运行。 这种情况的完美解决方案就像网络摄像头一样: https ://stackoverflow.com/questions/163476/free-alternative-to-webcron Obviously if you can use them - cro ...
  • 您在使用它之后定义$variable 。 移动 之前 var variable = ; You're defining $variable after using it. Move before var variable =
  • 未经测试,但你应该可以做这样的事......