CSR generation issue through API

stefantriep

Verified User
Joined
Dec 15, 2012
Messages
70
Location
Haarlem, The Netherlands
I'm trying to automate my request of a new SSL-certificate starting at the CSR.
Using DirectAdmin v 1.55.0 on CentOS 6.9 and the httpsocket.php v 3.0.2.

1. Connect to socket and login (check)
2. Login to account of user of the domain (check)
3. use CMD_API_SSL with action=> save and request => yes (check)

Code:
PHP:
$sock->query('/CMD_API_SSL',
	array(
		'domain' => str_replace('www.','',$domain['domain']),
		'action' => 'save',
		'type' => 'create',
		'request' => 'yes',
		'country' => $contact['countryCode'],
		'province' => $contact['province'],
		'city' => $contact['city'],
		'company' => $contact['company'],
		'division' => $contact['division'],
		'name' => $domain['domain'],
		'email' => $contact['email'],
		'keysize' => 4096,
		'encryption' => 'sha256',
	));			
$result = $sock->fetch_parsed_body();			
$csr = $result['request'];

4. Sending CSR to SSL-certificate supplier
When I send the CSR, the error "CSR can't be decoded" is hitting the logs.
If I print the CSR and copy paste it, the magic works, but sending through PHP seems to be an issue with the encoding I guess.

Can someone point me to the right direction? After reading al the Google results without the solution
 
Hello,


Try and change the last line to:

PHP:
$csr = html_entity_decode($result['request']);
 
Back
Top