DA PHP Api - Create DB

nservices

Verified User
Joined
Dec 11, 2008
Messages
302
Hi,
there is some Bug with SSL and DA Api?
am asking since I try to create DB via API and it's work without SSL
but not working with SSL
mean:
Code:
<?php 
$user   = "mydauser"; 
$pass   = "mydapass";
$server = "shared03.starltd.net";
$server_port=2222;
$server_ssl="N";

$dbname = "db1"; 
$dbuser   = "usr1"; 
$dbpass   = "passwd1"; 

include 'httpsocket.php'; 

$sock = new HTTPSocket; 
$sock->connect($server,2222); 

$sock->set_login($user,$pass); 

$sock->set_method('POST'); 

$sock->query('/CMD_API_DATABASES', 
    array( 
        'action' => 'create',
                'name' => 'db',
                'user' => 'dbuser',
                'passwd' => '$pass',
                'passwd2' => '$pass'
    )); 
$result = $sock->fetch_body(); 
echo $result;
work perfect, but when DirectAdmin panel working via SSL

Code:
<?php 
$user   = "mydauser"; 
$pass   = "mydapass";
$server = "shared03.starltd.net";
$server_port=2222;
$server_ssl="Y";

$dbname = "db1"; 
$dbuser   = "usr1"; 
$dbpass   = "passwd1"; 

include 'httpsocket.php'; 

$sock = new HTTPSocket; 
// $sock->connect($server,2222); 
$sock->connect("ssl://".$server,2222);
$sock->set_login($user,$pass); 

$sock->set_method('POST'); 

$sock->query('/CMD_API_DATABASES', 
    array( 
        'action' => 'create',
                'name' => 'db',
                'user' => 'dbuser',
                'passwd' => '$pass',
                'passwd2' => '$pass'
    )); 
$result = $sock->fetch_body(); 
echo $result;
not working at all and I got blank page.

any suggestions?
 
nothing, maybe it's some bug in DA?
something I missing?
even if I just changed the
$server = "shared03.starltd.net";
to $server = "ssl://shared03.starltd.net";
or $server = "https://shared03.starltd.net";
still nothing in response or in api debug mode
change back SSL=0 in directadmin.conf and restart directadmin and API is working well again
 
"nothing in response"... like not output at all as if nothing happened? That's strange.
Usually you get some output.

From this guide:
http://help.directadmin.com/item.php?id=15
Sometimes these 2 variables fight with APIs:

ssl_redirect_host

force_hostname

where they return with location redirects rather than executing your request..


But if it's not even connecting to 2222 at all with ssl, try 127.0.0.1 instead, just to see if that has any effect.

Also try connecting to other external places to see if works (if you have an external DA box to try with)

Could also be DA's ip blacklist if you connected too many times without auth:
/usr/local/directadmin/data/admin/ip_blacklist

John
 
Hi,
1. nothing in response mean no output on screen and nothing in DA debug
2. I removed both ssl_redirect_host and force_hostname, restart DA and same...
anyway, am using the right url and I try also with both IP or hostname
3. same with 127.0.0.1
4. since it's working without https, it's not look like blocking issue but anyway, we are not blocked at /usr/local/directadmin/data/admin/ip_blacklist
5. btw, from URL it's working: https://shared03.starltd.net:2222/C...name=db1&user=usr1&passwd=pass1&passwd2=pass1
from php script it's not working
Regards,
 
Bump instead of new thread.

On a new server with 1.50 we experience exact the same behavior. Zero response when we connect with ssl:// . Tried many ways, localhost, 127.0.0.1 ip etc etc. Just nogo at all.

Centos 7 & da 1.50
 
When you run DA in debug mode, does it move when you connect? It should show something in the DA server debug output if the connection is getting through.
Note that a socket connection happens before anything to do with ssl will occur.. so we should see something, probably an ssl cipher error or something like that, in the DA output.

So along that note, check your DA ciphers:
Code:
./directadmin c | grep cipher
and check to see if your script can work that high.

For example, if you're using CURL to connect to a secure socket with modern ciphers, you can force TLS1.2 like this
Code:
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
so if curl throws a fit, it's possible the openssl version (or php or curl) doesn't support that protocol.

If you're using the httpdsocket class... after reading the php manaul:
http://php.net/manual/en/function.fsockopen.php
you may be able to use tls:// rather than ssl:// but I've not tested this.

John
 
Back
Top