Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-407

SSL/TLS already set-up for this stream

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.0.0-rc0
    • Affects Version/s: 1.0.0-alpha2
    • Component/s: None
    • None

      --TEST--
      Connect to MongoDB with using X509 retrieving username from certificate #002
      --SKIPIF--
      <?php require __DIR__ . "/../utils/basic-skipif.inc"; NEEDS("STANDALONE_X509"); ?>
      --FILE--
      <?php
      require_once __DIR__ . "/../utils/basic.inc";
      
      function connect($dsn, $opts) {
      try {
          $manager = new MongoDB\Driver\Manager($dsn, array(), $opts);
      
          $bulk = new MongoDB\Driver\BulkWrite();
          $bulk->insert(array("very" => "important"));
          $manager->executeBulkWrite(NS, $bulk);
          echo "Connected\n";
      } catch(Exception $e) {
          echo get_class($e), ": ", $e->getMessage(), "\n";
      }
      
      }
      $SSL_DIR = realpath(__DIR__ . "/" . "./../../scripts/ssl/");
      $opts = array(
              "peer_name" => "server",
              "verify_peer" => true,
              "verify_peer_name" => true,
              "allow_self_signed" => false,
              "cafile" => $SSL_DIR . "/ca.pem", /* Defaults to openssl.cafile */
              "capath" => $SSL_DIR, /* Defaults to openssl.capath */
              "local_cert" => $SSL_DIR . "client.pem",
      );
      
      
      /* Wrong username */
      $parsed = parse_url(STANDALONE_X509);
      $dsn = sprintf("mongodb://username@%s:%d/%s?ssl=true&authMechanism=MONGODB-X509", $parsed["host"], $parsed["port"], DATABASE_NAME);
      connect($dsn, $opts);
      echo "second\n";
      connect($dsn, $opts);
      echo "done\n";
      
      

      The previously failed auth connection appears to be sticking around.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            bjori Hannes Magnusson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: