Created
June 27, 2013 13:57
-
-
Save vanbroup/5876621 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Just a quick and dirty API example for DNS verification | |
*/ | |
error_reporting(E_ALL); | |
/* | |
* Create a Private key | |
*/ | |
$dn = array( | |
"countryName" => "UK", | |
"stateOrProvinceName" => "Kent", | |
"localityName" => "Maidstone", | |
"organizationName" => "GMO GlobalSign Ltd.", | |
"commonName" => "www.domain.com", | |
); | |
$privkey = openssl_pkey_new(array('private_key_bits' => 2048)); | |
openssl_pkey_export($privkey, $pkeyout); | |
/* | |
* Create a Certificate Signing Request (CSR) | |
*/ | |
openssl_csr_export(openssl_csr_new($dn,$privkey), $csr); | |
// SOAP Settings | |
ini_set("soap.wsdl_cache_enabled", "0"); | |
$url = 'https://production.globalsign.com/kb/ws/v1/ServerSSLService?wsdl'; | |
$nameSpace = 'http://stub.orderbydns.gasapiserver.esp.globalsign.com'; | |
$client = new SoapClient($url,array('trace' => 1)); | |
$client->_namespace = $nameSpace; | |
// Your GlobalSign account details | |
$requestHeader = array(); | |
$requestHeader['AuthToken']['UserName'] = 'PAR123345_aaaaaaa'; | |
$requestHeader['AuthToken']['Password'] = '******************'; | |
// First you need to place an order | |
OrderByDNS($client, $requestHeader, $csr, 'www.domain.com'); | |
// Then when you have updated your DNS, you request the verification of the TXT record | |
//VerifyByDNS($client, $requestHeader, 'CEAP1306270157', 'domain.com'); | |
/* | |
* Order the SSL Certificate | |
*/ | |
function OrderByDNS($client, $requestHeader, $csr, $fqdn) { | |
$requestParameter = array(); | |
$requestParameter['ProductCode'] = 'DV_HIGH_DNS'; | |
$requestParameter['BaseOption'] = ''; | |
$requestParameter['OrderKind'] = 'new'; | |
$requestParameter['Licenses'] = 1; | |
$requestParameter['ValidityPeriod']['Months'] = 12; | |
$requestParameter['CSR'] = $csr; | |
$requestParameter['RenewalTargetOrderID'] = ''; | |
$requestParameter['TargetCERT'] = ''; | |
$requestParameter['SpecialInstructions'] = ''; | |
$requestParameter['Coupon'] = ''; | |
$requestParameter['Campaign'] = ''; | |
$params = array(); | |
$params['Request']['OrderRequestHeader'] = $requestHeader; | |
$params['Request']['OrderRequestParameter'] = $requestParameter; | |
$params['Request']['FQDN'] = $fqdn; | |
$params['Request']['SubID'] = ''; | |
$params['Request']['ContactInfo']['FirstName'] = 'First'; | |
$params['Request']['ContactInfo']['LastName'] = 'Last'; | |
$params['Request']['ContactInfo']['Phone'] = '999-999-9999'; | |
$params['Request']['ContactInfo']['Email'] = '[email protected]'; | |
$res = $client->__soapCall("DVDNSOrder", array('DVDNSOrder' => $params)); | |
print_r($res); | |
//echo $client->__getLastRequest() . PHP_EOL; | |
//echo $client->__getLastResponse() . PHP_EOL; | |
} | |
/* | |
* When you have uploaded the code, you can use the following command | |
* to verify the TXT record. Please note that the TXT record is case sensitive. | |
* | |
* To test your DNS TXT record: | |
* On Linux: dig @ns1.name-server.net domain.com TXT +short | |
* On Windows: nslookup -type=txt domain.com ns1.name-server.net | |
*/ | |
function VerifyByDNS($client, $requestHeader, $orderid, $fqdn) { | |
$params = array(); | |
$params['Request']['OrderRequestHeader'] = $requestHeader; | |
$params['Request']['OrderID'] = $orderid; | |
$params['Request']['ApproverFQDN'] = $fqdn; | |
$res = $client->__soapCall("DVDNSVerificationForIssue", array('DVDNSVerificationForIssue' => $params)); | |
print_r($res); | |
//echo $client->__getLastRequest() . PHP_EOL; | |
//echo $client->__getLastResponse() . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment