V
V
vladimircape2015-04-08 23:21:13
symfony
vladimircape, 2015-04-08 23:21:13

Symfony 2. Connecting to remote database via pem key?

Good afternoon.
Raised replication for Mongo on several servers.
I connect as in the documentation

$m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", array("replicaSet" => "myReplSetName"));

the question is, how to connect if these are remote servers and there is a pem key for each database?
So far I have found if the key is the same for everyone.
$ctx = stream_context_create(array(
    "ssl" => array(
        /* Optionally verify the server is who he says he is, and has been certified by CA we trust */
        "verify_peer"       => true,
        "allow_self_signed" => false,
        "cafile"            => "/vagrant/certs/ca.pem",
    ),
));

$mc = new MongoClient(
    "mongodb://server1", 
    array("ssl" => true), 
    array("context" => $ctx)
);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question