1<?php 2// This example uses X.509 certificates to authenticate on Couchbase Server 3// Read more about this feature at 4// 5// https://developer.couchbase.com/documentation/server/5.0/security/security-x509certsintro.html 6// 7// Also helper script, which generates certificates for local cluster, could be found here: 8// 9// https://gist.github.com/avsej/e1a05532b605ddd3a282734a6049a858 10 11// Certificate chain, which includes client public certificate (going first), and then concatenated with intermediate 12// and root certificates if they are not part of the system trusted certificates. 13$cert = "/tmp/x509-cert/SSLCA/clientdir/chain.pem"; 14// Private key for the client. Note that the username should be embedded into certificate on the generation stage into 15// corresponding field. In our example, we use CN and user "testuser", which has access to bucket "default". 16$key = "/tmp/x509-cert/SSLCA/clientdir/client.key"; 17 18// NOTE: that it have to use "couchbases://" schema ("https://" will also work) 19$cluster = new \Couchbase\Cluster("couchbases://127.0.0.1?certpath=$cert&keypath=$key"); 20$bucket = $cluster->openBucket("default"); 21$bucket->upsert("foo", ["bar" => 42]); 22