Subversion Repositories php-qbpwcf

Rev

Rev 291 | Rev 293 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 291 Rev 292
Line 6871... Line 6871...
6871
			return $result;
6871
			return $result;
6872
		
6872
		
6873
			}#if end
6873
			}#if end
6874
		
6874
		
6875
		#如果是 "pending_validation"
6875
		#如果是 "pending_validation"
6876
		if($json->status==="pending_validation"){
6876
		if($jsonRes->status==="pending_validation"){
6877
		
6877
		
6878
			#do nothing
6878
			#do nothing
6879
		
6879
		
6880
			}#if end
6880
			}#if end
6881
			
6881
			
6882
		#反之如果為 "issued"
6882
		#反之如果為 "issued"
6883
		else if($json->status==="issued"){
6883
		else if($jsonRes->status==="issued"){
6884
		
6884
		
6885
			#do nothing
6885
			#do nothing
6886
		
6886
		
6887
			}#else 
6887
			}#else 
6888
			
6888
			
Line 9105... Line 9105...
9105
				#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
9105
				#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
9106
				#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
9106
				#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
9107
				#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
9107
				#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
9108
				#必填參數:
9108
				#必填參數:
9109
				#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
9109
				#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
9110
				$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["info"]["share"]["ssl"]["pKey"]);
9110
				$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($cInfo["ssl"]["pKey"]);
9111
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9111
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9112
				$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
9112
				$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
9113
				#可省略參數:
9113
				#可省略參數:
9114
				#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
9114
				#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
9115
				#$conf["disableWebSearch"]="false";
9115
				#$conf["disableWebSearch"]="false";
Line 9214... Line 9214...
9214
					#必填參數:
9214
					#必填參數:
9215
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9215
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9216
					$conf["zerossl::writeTextIntoFile"]["fileArgu"]=__FILE__;
9216
					$conf["zerossl::writeTextIntoFile"]["fileArgu"]=__FILE__;
9217
					#可省略參數:
9217
					#可省略參數:
9218
					#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
9218
					#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
9219
					$conf["zerossl::writeTextIntoFile"]["fileName"]=$conf["info"]["share"]["ssl"]["pKey"];
9219
					$conf["zerossl::writeTextIntoFile"]["fileName"]=$cInfo["ssl"]["pKey"];
9220
					#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
9220
					#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
9221
					$conf["zerossl::writeTextIntoFile"]["inputString"]=$pKeyStr;
9221
					$conf["zerossl::writeTextIntoFile"]["inputString"]=$pKeyStr;
9222
					#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
9222
					#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
9223
					#$conf["writeMethod"]="a";
9223
					#$conf["writeMethod"]="a";
9224
					#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
9224
					#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
Line 9535... Line 9535...
9535
					#debug msg
9535
					#debug msg
9536
					echo "Request zerossl to validate certificate for domain name(".$cName.")".PHP_EOL;
9536
					echo "Request zerossl to validate certificate for domain name(".$cName.")".PHP_EOL;
9537
				
9537
				
9538
					}#if end
9538
					}#if end
9539
				
9539
				
9540
				#函式說明:
-
 
9541
				#請求驗證已經透過zerossl::createCertificate要求的domain.
-
 
9542
				#回傳結果:
-
 
9543
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
9544
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
9545
				#$result["function"],當前執行的函式名稱.
-
 
9546
				#$result["argu"],所使用的參數.
-
 
9547
				#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
9548
				#$result["content"],結果json字串.
-
 
9549
				#必填參數:
-
 
9550
				#$conf["id"],字串,zerossl::createCertificate回傳的id.
-
 
9551
				$conf["zerossl::verifyDomain"]["id"]=$csrId;
-
 
9552
				#可省略參數:
-
 
9553
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
-
 
9554
				$conf["zerossl::verifyDomain"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
-
 
9555
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
-
 
9556
				$conf["zerossl::verifyDomain"]["key"]=$conf["info"]["share"]["key"];
-
 
9557
				#參考資料:
-
 
9558
				#https://zerossl.com/documentation/api/verify-domains/
-
 
9559
				#備註:
-
 
9560
				#無.
9540
				#無窮迴圈
9561
				$verifyDomain=zerossl::verifyDomain($conf["zerossl::verifyDomain"]);
-
 
9562
				unset($conf["zerossl::verifyDomain"]);
-
 
9563
				
-
 
9564
				#如果執行異常
-
 
9565
				if($verifyDomain["status"]==="false"){
-
 
9566
				
-
 
9567
					#設置錯誤識別
-
 
9568
					$result["status"]="false";
-
 
9569
 
-
 
9570
					#設置錯誤訊息
-
 
9571
					$result["error"]=$verifyDomain;
-
 
9572
 
-
 
9573
					#回傳結果
-
 
9574
					return $result;
9541
				while(true){
9575
				
9542
				
-
 
9543
					#函式說明:
-
 
9544
					#請求驗證已經透過zerossl::createCertificate要求的domain.
-
 
9545
					#回傳結果:
-
 
9546
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
9547
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
9548
					#$result["function"],當前執行的函式名稱.
-
 
9549
					#$result["argu"],所使用的參數.
-
 
9550
					#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
9551
					#$result["content"],結果json字串.
-
 
9552
					#必填參數:
-
 
9553
					#$conf["id"],字串,zerossl::createCertificate回傳的id.
-
 
9554
					$conf["zerossl::verifyDomain"]["id"]=$csrId;
-
 
9555
					#可省略參數:
-
 
9556
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
-
 
9557
					$conf["zerossl::verifyDomain"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
-
 
9558
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
-
 
9559
					$conf["zerossl::verifyDomain"]["key"]=$conf["info"]["share"]["key"];
-
 
9560
					#參考資料:
-
 
9561
					#https://zerossl.com/documentation/api/verify-domains/
-
 
9562
					#備註:
9576
					}#if end
9563
					#無.
-
 
9564
					$verifyDomain=zerossl::verifyDomain($conf["zerossl::verifyDomain"]);
-
 
9565
					unset($conf["zerossl::verifyDomain"]);
9577
					
9566
					
9578
				#如果沒有回內容
-
 
9579
				if(!isset($verifyDomain["content"][0])){
-
 
9580
				
-
 
9581
					#設置錯誤識別
-
 
9582
					$result["status"]="false";
-
 
9583
 
-
 
9584
					#設置錯誤訊息
-
 
9585
					$result["error"]=$verifyDomain;
-
 
9586
 
-
 
9587
					#回傳結果
-
 
9588
					return $result;
-
 
9589
				
-
 
9590
					}#if end
-
 
9591
				
-
 
9592
				#如果回應不是 json
-
 
9593
				if(!(json_validate($verifyDomain["content"][0]))){
-
 
9594
				
-
 
9595
					#設置錯誤識別
-
 
9596
					$result["status"]="false";
-
 
9597
 
-
 
9598
					#設置錯誤訊息
-
 
9599
					$result["error"]=$verifyDomain;
-
 
9600
 
-
 
9601
					#回傳結果
-
 
9602
					return $result;
-
 
9603
				
-
 
9604
					}#if end
-
 
9605
				
-
 
9606
				/*
-
 
9607
				範例json:
-
 
9608
				{"id":"51cff04454e6a6860abfecc8072db602","type":"1","common_name":"silverblue-guest.qbpwcf.org","additional_domains":"","created":"2026-03-06 13:45:39","expires":"2026-06-04 23:59:59","status":"pending_validation","validation_type":"CNAME_CSR_HASH","validation_emails":"","replacement_for":"","fingerprint_sha1":null,"brand_validation":null,"validation":{"email_validation":{"silverblue-guest.qbpwcf.org":["admin@silverblue-guest.qbpwcf.org","administrator@silverblue-guest.qbpwcf.org","hostmaster@silverblue-guest.qbpwcf.org","postmaster@silverblue-guest.qbpwcf.org","webmaster@silverblue-guest.qbpwcf.org","admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"silverblue-guest.qbpwcf.org":{"file_validation_url_http":"http:\/\/silverblue-guest.qbpwcf.org\/.well-known\/pki-validation\/383346FA54F492EC8B2A6C421A052827.txt","file_validation_url_https":"https:\/\/silverblue-guest.qbpwcf.org\/.well-known\/pki-validation\/383346FA54F492EC8B2A6C421A052827.txt","file_validation_content":["58B9EB7890F754D041698170B22D22205D710ED09B419A809E5C92C38195DD36","comodoca.com","627e45f007045f0"],"cname_validation_p1":"_383346FA54F492EC8B2A6C421A052827.silverblue-guest.qbpwcf.org","cname_validation_p2":"58B9EB7890F754D041698170B22D2220.5D710ED09B419A809E5C92C38195DD36.627e45f007045f0.comodoca.com"}}},"signature_algorithm_properties":null}
9567
					#如果執行異常
9609
				*/
-
 
9610
				
-
 
9611
				#解析json回應
-
 
9612
				$verifyDomainRes=json_decode($verifyDomain["content"][0]);
-
 
9613
 
-
 
9614
				#如果是 zerossl 驗證失敗
-
 
9615
				if($verifyDomainRes->status==="false"){
9568
					if($verifyDomain["status"]==="false"){
9616
				
-
 
9617
					#如果是 CNAME 記錄找不到...
-
 
9618
				
9569
					
9619
					#設置錯誤識別
9570
						#設置錯誤識別
9620
					$result["status"]="false";
9571
						$result["status"]="false";
9621
 
-
 
9622
					#設置錯誤訊息
-
 
9623
					$result["error"]=$verifyDomain;
-
 
9624
 
9572
 
9625
					#回傳結果
9573
						#設置錯誤訊息
9626
					return $result;
9574
						$result["error"]=$verifyDomain;
9627
				
-
 
9628
					}#if end
-
 
9629
 
9575
 
9630
				#如果是 zerossl 尚在驗證中
-
 
9631
				if($verifyDomainRes->status==="pending_validation"){
-
 
9632
				
-
 
9633
					#if enable debug
-
 
9634
					if($debug){
9576
						#回傳結果
9635
					
-
 
9636
						#debug msg
9577
						return $result;
9637
						echo "Waiting zerossl to validate certificate for domain name(".$cName.")...".PHP_EOL;
-
 
9638
					
9578
					
9639
						}#if end
9579
						}#if end
9640
				
-
 
9641
					#無窮迴圈
-
 
9642
					while(true){
-
 
9643
				
-
 
9644
						#查詢驗證狀況
-
 
9645
						#函式說明:
-
 
9646
						#取得CSR在zerossl上的狀態
-
 
9647
						#回傳結果:
-
 
9648
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
9649
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
9650
						#$result["function"],當前執行的函式名稱.
-
 
9651
						#$result["argu"],所使用的參數.
-
 
9652
						#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
9653
						#$result["content"],結果json字串.
-
 
9654
						#$result["cerStatus"],csr在zerossl上的狀態,"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
-
 
9655
						#必填參數:
-
 
9656
						#$conf["id"],字串,zerossl::createCertificate回傳的id.
-
 
9657
						$conf["zerossl::getCertSta"]["id"]=$csrId;
-
 
9658
						#可省略參數:
-
 
9659
						#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
-
 
9660
						$conf["zerossl::getCertSta"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
-
 
9661
						#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
-
 
9662
						$conf["zerossl::getCertSta"]["key"]=$conf["info"]["share"]["key"];
-
 
9663
						#參考資料:
-
 
9664
						#https://zerossl.com/documentation/api/get-certificate/
-
 
9665
						#備註:
-
 
9666
						#無.
-
 
9667
						$getCertSta=zerossl::getCertSta($conf["zerossl::getCertSta"]);
-
 
9668
						unset($conf["zerossl::getCertSta"]);
-
 
9669
						
9580
						
9670
						#如果執行異常
9581
					#如果沒有回內容
9671
						if($getCertSta["status"]==="false"){
9582
					if(!isset($verifyDomain["content"][0])){
9672
						
9583
					
9673
							#設置錯誤識別
9584
						#設置錯誤識別
9674
							$result["status"]="false";
9585
						$result["status"]="false";
9675
 
-
 
9676
							#設置錯誤訊息
-
 
9677
							$result["error"]=$getCertSta;
-
 
9678
 
9586
 
9679
							#回傳結果
-
 
9680
							return $result;
-
 
9681
						
-
 
9682
							}#if end
-
 
9683
							
-
 
9684
						#如果沒有回應內容
-
 
9685
						if(!isset($getCertSta["content"][0])){
-
 
9686
						
-
 
9687
							#設置錯誤識別
9587
						#設置錯誤訊息
9688
							$result["status"]="false";
9588
						$result["error"]=$verifyDomain;
9689
 
9589
 
-
 
9590
						#回傳結果
-
 
9591
						return $result;
-
 
9592
					
-
 
9593
						}#if end
-
 
9594
					
-
 
9595
					#如果回應不是 json
-
 
9596
					if(!(json_validate($verifyDomain["content"][0]))){
-
 
9597
					
9690
							#設置錯誤訊息
9598
						#設置錯誤識別
9691
							$result["error"]=$getCertSta;
9599
						$result["status"]="false";
9692
 
9600
 
9693
							#回傳結果
-
 
9694
							return $result;
-
 
9695
						
-
 
9696
							}#if end
-
 
9697
							
-
 
9698
						#如果回應不是 json
-
 
9699
						if(!(json_validate($getCertSta["content"][0]))){
-
 
9700
						
-
 
9701
							#設置錯誤識別
9601
						#設置錯誤訊息
9702
							$result["status"]="false";
9602
						$result["error"]=$verifyDomain;
9703
 
9603
 
9704
							#設置錯誤訊息
9604
						#回傳結果
-
 
9605
						return $result;
-
 
9606
					
-
 
9607
						}#if end
-
 
9608
					
-
 
9609
					/*
-
 
9610
					範例json:
9705
							$result["error"]=$getCertSta;
9611
					{"id":"51cff04454e6a6860abfecc8072db602","type":"1","common_name":"silverblue-guest.qbpwcf.org","additional_domains":"","created":"2026-03-06 13:45:39","expires":"2026-06-04 23:59:59","status":"pending_validation","validation_type":"CNAME_CSR_HASH","validation_emails":"","replacement_for":"","fingerprint_sha1":null,"brand_validation":null,"validation":{"email_validation":{"silverblue-guest.qbpwcf.org":["admin@silverblue-guest.qbpwcf.org","administrator@silverblue-guest.qbpwcf.org","hostmaster@silverblue-guest.qbpwcf.org","postmaster@silverblue-guest.qbpwcf.org","webmaster@silverblue-guest.qbpwcf.org","admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"silverblue-guest.qbpwcf.org":{"file_validation_url_http":"http:\/\/silverblue-guest.qbpwcf.org\/.well-known\/pki-validation\/383346FA54F492EC8B2A6C421A052827.txt","file_validation_url_https":"https:\/\/silverblue-guest.qbpwcf.org\/.well-known\/pki-validation\/383346FA54F492EC8B2A6C421A052827.txt","file_validation_content":["58B9EB7890F754D041698170B22D22205D710ED09B419A809E5C92C38195DD36","comodoca.com","627e45f007045f0"],"cname_validation_p1":"_383346FA54F492EC8B2A6C421A052827.silverblue-guest.qbpwcf.org","cname_validation_p2":"58B9EB7890F754D041698170B22D2220.5D710ED09B419A809E5C92C38195DD36.627e45f007045f0.comodoca.com"}}},"signature_algorithm_properties":null}
-
 
9612
					*/
-
 
9613
					
-
 
9614
					#解析json回應
-
 
9615
					$verifyDomainRes=json_decode($verifyDomain["content"][0]);
9706
 
9616
 
-
 
9617
					#如果是 zerossl 驗證失敗
-
 
9618
					if($verifyDomainRes->status==="false"){
-
 
9619
					
9707
							#回傳結果
9620
						#如果是 CNAME 記錄找不到
9708
							return $result;
9621
						if($verifyDomainRes->error->code===0){
9709
						
9622
						
9710
							}#if end
9623
							#取得錯誤訊息
-
 
9624
							#$error_info_zerossl=$verifyDomainRes->error->details->$cName->error_info;
9711
							
9625
							
9712
						#解析json回應
-
 
9713
						$getCertStaRes=json_decode($getCertSta["content"][0]);
-
 
9714
						
-
 
9715
						#如果憑證已經驗證通過了
-
 
9716
						if($getCertStaRes->status==="issued"){
-
 
9717
						
-
 
9718
							#if enable debug
9626
							#if enable debug
9719
							if($debug){
9627
							if($debug){
9720
							
9628
							
9721
								#debug msg
9629
								#debug msg
9722
								echo "Zerossl validated certificate for domain name(".$cName.").".PHP_EOL;
9630
								echo "Zerossl can't find DNS CNAME record to validate certificate for domain name(".$cName.").".PHP_EOL;
9723
							
9631
							
9724
								}#if end
9632
								}#if end
9725
						
-
 
9726
							#結束等待
-
 
9727
							break;
-
 
9728
						
-
 
9729
							}#if end
-
 
9730
							
9633
							
9731
						#如果 zerossl 尚在處理中
-
 
9732
						else if($getCertStaRes->status==="pending_validation"){
-
 
9733
						
-
 
9734
							#if enable debug
9634
							#if enable debug
9735
							if($debug){
9635
							if($debug){
9736
							
9636
							
9737
								#debug msg
9637
								#debug msg
9738
								echo "Waiting zerossl to validate certificate for domain name(".$cName.")...".PHP_EOL;
9638
								echo "Waiting DNS CNAME record distributed to the world for domain name(".$cName.").".PHP_EOL;
9739
							
9639
							
9740
								}#if end
9640
								}#if end
9741
								
9641
							
9742
							#休息1分鐘
9642
							#休息60秒
9743
							sleep(60);
9643
							sleep(60);
9744
						
9644
						
9745
							}#if end
9645
							}#if end
9746
						
9646
							
9747
						#反之
9647
						#反之為不接受的錯誤訊息
9748
						else{
9648
						else{
9749
						
9649
						
9750
							#例外狀況
-
 
9751
							
-
 
9752
							#設置錯誤識別
9650
							#設置錯誤識別
9753
							$result["status"]="false";
9651
							$result["status"]="false";
9754
 
9652
 
9755
							#設置錯誤訊息
9653
							#設置錯誤訊息
9756
							$result["error"]=$getCertSta;
9654
							$result["error"]=$verifyDomain;
9757
 
9655
 
9758
							#回傳結果
9656
							#回傳結果
9759
							return $result;
9657
							return $result;
9760
						
9658
						
9761
							}#else end
9659
							}#else end
-
 
9660
					
-
 
9661
						}#if end
-
 
9662
					
-
 
9663
					#如果是 zerossl 尚在驗證中
-
 
9664
					else if($verifyDomainRes->status==="pending_validation"){
-
 
9665
					
-
 
9666
						#if enable debug
-
 
9667
						if($debug){
-
 
9668
						
-
 
9669
							#debug msg
-
 
9670
							echo "Waiting zerossl to validate certificate for domain name(".$cName.")...".PHP_EOL;
-
 
9671
						
-
 
9672
							}#if end
-
 
9673
							
-
 
9674
						#無窮迴圈
-
 
9675
						while(true){
-
 
9676
					
-
 
9677
							#查詢驗證狀況
-
 
9678
							#函式說明:
-
 
9679
							#取得CSR在zerossl上的狀態
-
 
9680
							#回傳結果:
-
 
9681
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
9682
							#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
9683
							#$result["function"],當前執行的函式名稱.
-
 
9684
							#$result["argu"],所使用的參數.
-
 
9685
							#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
9686
							#$result["content"],結果json字串.
-
 
9687
							#$result["cerStatus"],csr在zerossl上的狀態,"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
-
 
9688
							#必填參數:
-
 
9689
							#$conf["id"],字串,zerossl::createCertificate回傳的id.
-
 
9690
							$conf["zerossl::getCertSta"]["id"]=$csrId;
-
 
9691
							#可省略參數:
-
 
9692
							#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
-
 
9693
							$conf["zerossl::getCertSta"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
-
 
9694
							#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
-
 
9695
							$conf["zerossl::getCertSta"]["key"]=$conf["info"]["share"]["key"];
-
 
9696
							#參考資料:
-
 
9697
							#https://zerossl.com/documentation/api/get-certificate/
-
 
9698
							#備註:
-
 
9699
							#無.
-
 
9700
							$getCertSta=zerossl::getCertSta($conf["zerossl::getCertSta"]);
-
 
9701
							unset($conf["zerossl::getCertSta"]);
-
 
9702
							
-
 
9703
							#如果執行異常
-
 
9704
							if($getCertSta["status"]==="false"){
-
 
9705
							
-
 
9706
								#設置錯誤識別
-
 
9707
								$result["status"]="false";
-
 
9708
 
-
 
9709
								#設置錯誤訊息
-
 
9710
								$result["error"]=$getCertSta;
-
 
9711
 
-
 
9712
								#回傳結果
-
 
9713
								return $result;
-
 
9714
							
-
 
9715
								}#if end
-
 
9716
								
-
 
9717
							#如果沒有回應內容
-
 
9718
							if(!isset($getCertSta["content"][0])){
-
 
9719
							
-
 
9720
								#設置錯誤識別
-
 
9721
								$result["status"]="false";
-
 
9722
 
-
 
9723
								#設置錯誤訊息
-
 
9724
								$result["error"]=$getCertSta;
-
 
9725
 
-
 
9726
								#回傳結果
-
 
9727
								return $result;
-
 
9728
							
-
 
9729
								}#if end
-
 
9730
								
-
 
9731
							#如果回應不是 json
-
 
9732
							if(!(json_validate($getCertSta["content"][0]))){
-
 
9733
							
-
 
9734
								#設置錯誤識別
-
 
9735
								$result["status"]="false";
-
 
9736
 
-
 
9737
								#設置錯誤訊息
-
 
9738
								$result["error"]=$getCertSta;
9762
 
9739
 
-
 
9740
								#回傳結果
-
 
9741
								return $result;
-
 
9742
							
-
 
9743
								}#if end
-
 
9744
								
-
 
9745
							#解析json回應
-
 
9746
							$getCertStaRes=json_decode($getCertSta["content"][0]);
-
 
9747
							
-
 
9748
							#如果憑證已經驗證通過了
-
 
9749
							if($getCertStaRes->status==="issued"){
-
 
9750
							
-
 
9751
								#if enable debug
-
 
9752
								if($debug){
-
 
9753
								
-
 
9754
									#debug msg
-
 
9755
									echo "Zerossl validated certificate for domain name(".$cName.").".PHP_EOL;
-
 
9756
								
-
 
9757
									}#if end
-
 
9758
							
-
 
9759
								#結束等待
-
 
9760
								break 2;
-
 
9761
							
-
 
9762
								}#if end
-
 
9763
								
-
 
9764
							#如果 zerossl 尚在處理中
-
 
9765
							else if($getCertStaRes->status==="pending_validation"){
-
 
9766
							
-
 
9767
								#if enable debug
-
 
9768
								if($debug){
-
 
9769
								
-
 
9770
									#debug msg
-
 
9771
									echo "Waiting zerossl to validate certificate for domain name(".$cName.")...".PHP_EOL;
-
 
9772
								
-
 
9773
									}#if end
-
 
9774
									
-
 
9775
								#休息1分鐘
-
 
9776
								sleep(60);
-
 
9777
							
-
 
9778
								}#if end
-
 
9779
							
-
 
9780
							#反之
-
 
9781
							else{
-
 
9782
							
-
 
9783
								#例外狀況
-
 
9784
								
-
 
9785
								#設置錯誤識別
-
 
9786
								$result["status"]="false";
-
 
9787
 
-
 
9788
								#設置錯誤訊息
-
 
9789
								$result["error"]=$getCertSta;
-
 
9790
 
-
 
9791
								#回傳結果
-
 
9792
								return $result;
-
 
9793
							
-
 
9794
								}#else end
-
 
9795
 
9763
						}#while end
9796
							}#while end
-
 
9797
					
-
 
9798
						}#if end
9764
				
9799
				
9765
					}#if end
9800
					}#while end
9766
 
9801
 
9767
				#if enable debug
9802
				#if enable debug
9768
				if($debug){
9803
				if($debug){
9769
				
9804
				
9770
					#debug msg
9805
					#debug msg