Skip to content

Conversation

@ronindesign
Copy link

@ronindesign ronindesign commented Dec 22, 2017

Authenticate and call install_ssl via WHM API instead of cPanel UAPI.
Requires WHM access, common for reseller accounts (not shared hosting)
Using a token is safer than basic authentication, allows access control, and revoke.
Ref: https://documentation.cpanel.net/display/SDK/Use+WHM+API+to+Call+cPanel+API+and+UAPI

@ronindesign ronindesign force-pushed the whm-token-authentication branch from 77f9dc8 to 50328d9 Compare December 22, 2017 12:51
@ronindesign ronindesign force-pushed the whm-token-authentication branch from 50328d9 to d95eb26 Compare December 22, 2017 13:02
@neurobin
Copy link
Owner

I think there's a problem here:

elseif (!$GLOBALS['token'] && !$response->status ) {
    $msg = json_encode($response);
    err("The CURL call returned valid JSON, but reported errors: $msg");
} elseif ( !$response->result->status ) {
    $msg = json_encode($response);
    err("The CURL call returned valid JSON, but reported errors: $msg");
}

when response is good, and the token method is not used, elseif ( !$response->result->status ) checks a condition on an invalid variable $response->result->status.

A solution may be this:

elseif (!$GLOBALS['token']){
    if(!$response->status ) {
        $msg = json_encode($response);
        err("The CURL call returned valid JSON, but reported errors: $msg");
    }
} elseif ( !$response->result->status ) {
    $msg = json_encode($response);
    err("The CURL call returned valid JSON, but reported errors: $msg");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants