Solved API - Can't create socket connection

Muni3k

Verified User
Joined
Mar 19, 2014
Messages
13
Good evening,

i have problem with API and SSL on my instance. With SSL on i can not get values by API.

Here is directadmin.conf contents (most important variables for this problem):
Code:
SSL=1
check_referer=1
port=2222
ssl_redirect_host=da.mydomain.com:443
force_hostname=da.mydomain.com

And here is error that i get while i am using API:
Code:
HTTPSocket Object
(
    [version] => 2.7.2
    [method] => GET
    [remote_host] => ssl://da.mydomain.com
    [remote_port] => 2222
    [remote_uname] => admin
    [remote_passwd] => MY_PASSWORD
    [result] =>
    [result_header] =>
    [result_body] =>
    [result_status_code] =>
    [lastTransferSpeed] =>
    [bind_host] =>
    [error] => Array
        (
            [0] => Can't create socket connection to ssl://da.mydomain.com:2222.
        )

    [warn] => Array
        (
        )

    [query_cache] => Array
        (
        )

    [doFollowLocationHeader] => 1
    [redirectURL] =>
    [max_redirects] => 5
    [ssl_setting_message] => DirectAdmin appears to be using SSL. Change your script to connect to ssl://
    [extra_headers] => Array
        (
        )

)

After changing:
Code:
SSL=0
ssl_redirect_host=da.mydomain.com
everything works fine but SSL on website is off.

Another problem is that after i have added:
Code:
force_hostname=da.mydomain.com
to directadmin.conf address of the website ends with port ":2222". Am I able to remove it? Just to force use https (443) port?
 
Last edited:
Good remark on the port. Thanks. Does Directadmin on your server run on 443? According to your listing... it does not:

Code:
port=2222
ssl_redirect_host=da.mydomain.com:443

If you are sure that SSL/TLS cert is fine, then check firewall settings, it should allow outgoing and incoming connections to 2222, of course if Directadmin runs on 2222 port.
 
No, DA runs on 2222. I have changed ssl_redirect_host to port '2222'. It didn't helped.

I have clear iptables (all policies set to ACCEPT) and service firewall is stopped.

Is there any way to check SSL on DirectAdmin? Only this option (SSL) has influence on this problem.
 
I am using PHP 5.6:
root@host:~/...# php -v
PHP 5.6.29 (cli) (built: Mar 25 2017 22:26:15)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.8, Copyright (c) 2002-2016, by ionCube Ltd.

I have the same errors as the person who created mentioned thread (after removing @):
PHP Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /root/httpsocket.php on line 190
PHP Warning: fsockopen(): Failed to enable crypto in /root/httpsocket.php on line 190
PHP Warning: fsockopen(): unable to connect to ssl://da.mydomain.com:2222 (Unknown error) in /root/httpsocket.php on line 190

I have tried all things from thread 50885 but still i see no change.
 
Problem solved. I had to enter indirect certs from my issuer to cert.pem file. Thank you for your interest.
 
I have the same issue when i want to change the password in roundcube.
Roundcube is working fine accept for the password change. Then i get
DirectAdmin appears to be using SSL. Change your script to connect to ssl://

I have set :
ssl_ignore_when_local=1
email_ftp_password_change=1

Running on the latest version available at this moment
 
I had the same issue, its because the force ssl option in directadmin.conf is enabled. Just change "$config['password_directadmin_host'] = 'tcp://localhost';" to "$config['password_directadmin_host'] = 'ssl://localhost';" in /var/www/html/roundcube/plugins/password/config.inc.php
 
Back
Top