Closed wuknet closed 4 years ago
I am not sure what the cause is of the HTTP 504 in this case. I haven't seen it. Have you had it as well with the example code including your own domains/data?
P.s. your code is hardly readable without code tags
@yourivw Should be probably closed, issue is hard to read.
@mvorisek Agree, closing it, thanks.
The following code, Step = 1, has an error 504 Gateway Time-out ///////////////////////////////////////////////////////////////////////////// `<?php header("Content-type: text/html; charset=utf-8"); ini_set('max_execution_time', 120); include DIR.'/LEClient/vendor/autoload.php';
// Importing the classes. use LEClient\LEClient; use LEClient\LEOrder;
session_start(); $userid = $_SESSION['userid']; $myemail = $_SESSION['email']; $mydomain = $_SESSION['domain'];
if($userid==0) { die('请先登录!'); }
echo "信息>UserID:".$userid.",邮箱:".$myemail.",域名:".$mydomain."
";
$email = array($myemail); $basename = $mydomain; $domains = array($basename,'*.'.$basename);
//$domains = array('*.887d.com');
//https://acme-v02.api.letsencrypt.org //第二参数true是测试,false是正式使用 $client = new LEClient($email, false, LECLient::LOG_STATUS, "cert/$basename/");//第二参数true是测试,false是正式使用,第四个参数是路径 //$client = new LEClient($email, true, LECLient::LOG_DEBUG);
//获取或创建订单。基本名称最好是顶级域名。这将是存储密钥的目录。提供一组字符串域名来为其创建证书。 $order = $client->getOrCreateOrder($basename, $domains); //var_dump($order);
$step = get_(0,"step");
if(!$order->allAuthorizationsValid())//检查此订单实例中的所有授权是否有效。 { $pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS);//获取dns验证记录 //var_dump($pending);
} else //所有授权有效了,就获取证书 { getcert($order);//获取证书 } // Check once more whether all authorizations are valid before we can finalize the order.
function getcert($order) { global $userid,$myemail,$mydomain; // Finalize the order first, if that is not yet done. if(!$order->isFinalized()) $order->finalizeOrder(); // Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate. if($order->isFinalized()) {
$order->getCertificate(); echo "开始保存数据库
"; include("../config_database.php"); include("../conn.php"); $expiretime = date('Y-m-d H:i:s',strtotime("+3 month")); $result = $db->prepare("select sslid,userid,email,basename,domains,signtime,expiretime from wuk_ssl where basename=?"); $result->bindParam(1,$mydomain); $result->execute(); if($rs=$result->fetch(PDO::FETCH_ASSOC)) { $db->exec("update wuk_ssl set signtime='".gettime()."',expiretime='".$expiretime."' where basename='".$mydomain."'"); echo "成功完成SSL证书的续期。
"; } else { $db->exec("insert into wuk_ssl(userid,email,basename,domains,signtime,expiretime) values (".$userid.",'".$myemail."','".$mydomain."','".$mydomain.",*.".$mydomain."','".gettime()."','".$expiretime."')");//添加进数据库 echo "成功完成SSL证书的申请。
"; } echo "<a href=\"/ssl.php\" target=\"_top\">返回证书管理查看";
} ////////////////////////////////////////////////////// function gettime() //获取时间 { ini_set('date.timezone','Asia/Shanghai'); return date("Y-m-d H:i:s",time()); }
function get_($datatype,$getvalue) { if($datatype==0) { if (isset($_GET[$getvalue])) $revalue=intval($_GET[$getvalue]); else $revalue=0; } else { if (isset($_GET[$getvalue])) $revalue=$_GET[$getvalue]; else $revalue=""; } return $revalue; }
function post_($datatype,$getvalue) { if($datatype==0) { if (isset($_POST[$getvalue])) $revalue=intval($_POST[$getvalue]); else $revalue=0; } else { if (isset($_POST[$getvalue])) $revalue=$_POST[$getvalue]; else $revalue=""; } return $revalue; } ?>`