1

I'm trying to change a password on a z/OS mainframe that I make an FTPS connection to. Working with a legacy codebase and I'm trying to get rid of the exec calls to cURL. You'll notice all the certificate skipping in the old call...

$exec_string = "CURL -q -v -k -S --ftp-ssl-reqd \"ftp://" . $hold_user['dm_ftphost'] . "/\" --user " . $hold_user['dm_ftpuser'] . ":" . $hold_user['dm_ftppass'] . "/" . $new_pass . "/" . $new_pass . " -Q \"cdup\"";

I have been unable to translate this to the cURL PHP module. I've tried different combinations of CURLOPT_USER, CURLOPT_PASS, and CURLOPT_USERPWD.

As an example of what I've tried...

public function updatePassword($newPass) {
        $options = [
            CURLOPT_URL   => "ftp://" . $this->credentials->getField(Ftp_Credentials::HOST),
            CURLOPT_USERPWD =>  $this->credentials->getField(Ftp_Credentials::USER, ret_aes_pass()) . ":" . $this->credentials->getField(Ftp_Credentials::PASS, ret_aes_pass())
                . "/{$newPass}/{$newPass}"
        ];
        return $this->returnSetResult($this->curl($options));
    }

I know I have to update my password at login so there are few options I can use.

Below are my options for every cURL connection I make in case one of these is keeping me from setting my new password. (I did comment out CURLOPT_USERNAME and CURLOPT_PASSWORD when I tested the above function)

        $options += [
            CURLOPT_FORBID_REUSE     => true,
            CURLOPT_FTP_USE_EPSV     => false,
            CURLOPT_FTP_SKIP_PASV_IP => true,
            CURLOPT_USERNAME         => $this->credentials->getField(Ftp_Credentials::USER, KDRS_AES_KEY),
            CURLOPT_PASSWORD         => $this->credentials->getField(Ftp_Credentials::PASS, KDRS_AES_KEY),
            CURLOPT_PORT             => $this->credentials->getField(Ftp_Credentials::PORT),
            CURLOPT_VERBOSE          => true,
            CURLOPT_FAILONERROR      => true,
            //CURLOPT_FOLLOWLOCATION   => true,
            CURLOPT_TIMEOUT          => 15,
            // SSL options for secure connection
            CURLOPT_FTP_SSL          => CURLFTPSSL_ALL,              // Use SSL/TLS for FTP
            CURLOPT_FTPSSLAUTH       => CURLFTPAUTH_TLS,             // Authenticate using TLS
            CURLOPT_SSLVERSION       => CURL_SSLVERSION_TLSv1_2,     // Use TLS 1.2 explicitly
            CURLOPT_SSL_VERIFYPEER   => true,                        // Verify the peer's SSL certificate
            CURLOPT_SSL_VERIFYHOST   => self::SSL_VERIFY_HOST_ENABLED,                           // Verify the host's name matches the SSL certificate
            CURLOPT_CAINFO           => PATH_CA_BUNDLE               // Path to your CA certificate bundle
        ];
21
  • incarnate.github.io/curl-to-php
    – Barmar
    Commented Apr 18 at 22:27
  • This is a lazy and unhelpful comment. Commented Apr 18 at 23:24
  • In the curl command you have user:oldpass/newpass/newpass. In PHP you have user:oldpass:newpass:newpass. So you're using : where you should be using / between the passwords.
    – Barmar
    Commented Apr 19 at 0:37
  • Yes, I was trying anything, even grasping at straws by adding colons and spaces. I've tried user:old/new/new also. I'll edit this sometime in the future with all the combinations I've tried. Commented Apr 19 at 0:55
  • Are you getting any specific errors in the response the remote server sends back to your php attempts?
    – ADyson
    Commented Apr 19 at 7:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.