0

webAppA と webAppB という 2 つの Web アプリケーションがあります。webAppA は、https 8443 で実行されている tomcat7 にデプロイされています。これは、基本認証スキームを使用して RESTful サービスを提供します。webAppB は、webAppA を認証に使用し、いくつかの REST リソースを表示する PHP ベースの Web アプリケーションです。これは、https 443 経由で apache2 にデプロイされています。何が間違っているのか誰でも助けてくれますか? http 接続を担当する webAppB のコード スニペットを以下に示します。

/**
 * Check the username / password against the other webAppA$
 */
function webAppA_auth_check($username, $password) {

  require_once("auth-functions.php");
  require_once("HTTP/Request2.php");

  $bare_base_url = localhost
  // using basic authentication
  $url =  https://'.$username.':'.$password.'@'.$bare_base_url.':8443/app/ws/rest/v1/session';

  $request = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
  $request->setConfig(
      array(
          'ssl_verify_peer'   => false,
          'ssl_verify_host'   => false,
      )
  );
  try {
    $response = $request->send();
  } catch (HTTP_Request2_Exception $e) {
    echo 'Error: ' . $e->getMessage();
    var_dump($e->getMessage());
    exit();
  }
}

例外を以下に示します。

Error: Unable to connect to ssl://123@localhost:8443. Error: php_network_getaddresses: getaddrinfo failed: Name or service not knownstring(127) "Unable to connect to ssl://123@localhost:8443. Error: php_network_getaddresses: getaddrinfo failed: Name or service not known"

PS: ユーザー名はダミー、パスワードはダミーです123

4

1 に答える 1

1

http リクエストの代わりにCurlを使用するだけです

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  curl_setopt( $ch, CURLOPT_URL, $url );
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  $response = curl_exec($ch);
  print_r($response);
于 2013-10-19T09:56:56.263 に答える