このページの翻訳:
- 日本語 (ja)
- English (en)
最近の更新
- 2024.01.18 RailsでSSLエラー 以前のリビジョンを復元 (2024/01/18 07:06)
- 31 CentOS5 TLS1.2 created
- 2024.04.12 MySQL BIT Field created
最近の更新
文書の過去の版を表示しています。
今回はValueドメインでドメインを管理している場合の方法
必要になるcertbotとphp-cli php-curlをインストール
snap install --classic certbot apt install php-cli php-curl
[APIKEY]はValueドメインにログイン後、マイページ → バリュードメインAPI で作ったAPIKEYを利用。
vapi_post.php
<?php $apikey = '[APIKEY]'; $url = "https://api.value-domain.com/v1"; $path = "/domains/$argv[1]/dns"; $method = "POST"; $CERTBOT_VALIDATION=$argv[2]; $IP=$argv[3]; $postfields = array( "ns_type" => "valuedomain1", "records" => "a @ ${IP}\na * ${IP}\ntxt _acme-challenge ${CERTBOT_VALIDATION}\n", "ttl" => "120", ); $post_query = json_encode($postfields); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url . $path); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); if ($method!=='GET') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);//FIXME use http version 1.1 } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $headers = array(); $headers[] = "Content-Type: application/json"; if ($method!=='GET') { $headers[] = 'Content-Length: ' . strlen($post_query); } $headers[] = 'Authorization: Bearer ' . $apikey; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Connection Error: ' . curl_errno($ch) . ' - ' . curl_error($ch);exit; } $info = curl_getinfo($ch); print_r($response); curl_close($ch); ?>
/root/vapi.sh
#!/bin/bash ETH=eth0 script=/root/vapi_post.php IP=`ip -4 a | grep inet.*${ETH} | awk '{print $2}' | sed 's/\/.*//g'` php $script ${CERTBOT_DOMAIN} ${CERTBOT_VALIDATION} ${IP} sleep 120 exit $?
domain=hogehoge.com mail=hoge@hogehoge.com certbot certonly --manual \ --preferred-challenges dns-01 \ --server https://acme-v02.api.letsencrypt.org/directory \ -m ${mail} \ -d ${domain} \ -d *.${domain} \ --manual-auth-hook=/root/vapi.sh