简体   繁体   中英

Nusoap doesn't work with PHP password_hash function?

I am write a simple web service for login process from .net. I am using nusoap php library for server side. In that server side I am hashing to given password and query it in database to check if there is such that hashed password. But in .net I am getting error that the response is text/html format while it waitings text/xml format. Error is password_hash function doesn't founden but this is php's built-in function. And I check that functions in seperate .php file and it works without error same for encrypting and decrypting(password_verify). So where am I going wrong in this situation? 在此处输入图片说明 在此处输入图片说明

This is my code;

function systemLogin($mycomplexlogin)
{
    $result=NULL;
    $conn=openConnection();
    // Check connection
    if ($conn->connect_error)
    {
        //return("Connection failed: " . $conn->connect_error);
        return $result;
    } 
    $EnterpriseId=mysqli_real_escape_string($conn,$mycomplexlogin["EnterpriseId"]);
    $UserName=mysqli_real_escape_string($conn,$mycomplexlogin["UserName"]);
    $Password=$mycomplexlogin["Password"];
    $cost=10;
    $hash="";
    $hash=password_hash($Password, PASSWORD_BCRYPT, ["cost" => $cost]);
    /* create a prepared statement */
    $stmt =  $conn->stmt_init();
    // prepare and bind
    if($stmt = $conn->prepare("SELECT * FROM mydatabase.USERS WHERE BINARY  username=?"))
    {
        $stmt->bind_param("s", $UserName);
        // execute query
        $stmt->execute();
        /* bind result variables */
        $stmt->bind_result($resultId,$resultLastName,$resultFirstName,$resultAddress,$resultPosition,$resultManager,$resultUserName,$resultPass);
        /* fetch value */
        if($stmt->fetch()) 
        {
            if(password_verify($Password,$hash))
            {
            //date("Y-m-d H:i:s");
            $token=date("Y-m-d H:i:s");
            $result= array(
            'Id' => $resultId,
            'LastName'=>$resultLastName,
            'FirstName' => $resultFirstName,
            'Address'=>$resultAddress,
            'Position'=>$resultPosition,
            'Manager'=>$resultManager,
            'Password' => $resultPass,
            'UserName' => $resultUserName,
            'Token' => $token
            );
            }
        }
        // close statement
        $stmt->close();
    }
    mysqli_close($conn);
    return $result;
}

Looks like something's wrong with your headers. The server should be sending back

header("Content-Type: text/xml\r\n");

but instead its sending back

header("Content-Type: text/html\r\n");

maybe check your WSDL file or figure out why your not outputing xml back to the client

I wonder if your hitting this error https://github.com/fergusean/nusoap/blob/463c772ae805aed7f396d89e6dce1dc0ce4c038b/lib/class.soap_server.php#L295

Update# I found solution. In PHP-7 even if PHP's Manual Page says password_hash is inbuilt when I call it in nusoaps server side it doesn't recognize this function. When I call it seperate .php page it works. So at the end I download password hashing library from github and it works perfectly. I guess, I install PHP-7 wrongly or it is a bug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM