$db = $adminer->database();
set_error_handler(array($this, '_error'));
$this->_string = "host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' user='" . addcslashes($username, "'\\") . "' password='" . addcslashes($password, "'\\") . "'";
+ $ssl = $adminer->connectSsl();
+ if (isset($ssl["mode"])) {
+ $this->_string .= " sslmode='" . $ssl["mode"] . "'";
+ }
$this->_link = @pg_connect("$this->_string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'", PGSQL_CONNECT_FORCE_NEW);
if (!$this->_link && $db != "") {
// try to connect directly with database for performance
function connect($server, $username, $password) {
global $adminer;
$db = $adminer->database();
- $this->dsn("pgsql:host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' client_encoding=utf8 dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'", $username, $password); //! client_encoding is supported since 9.1 but we can't yet use min_version here
- //! connect without DB in case of an error
+ //! client_encoding is supported since 9.1, but we can't yet use min_version here
+ $dsn = "pgsql:host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' client_encoding=utf8 dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'";
+ $ssl = $adminer->connectSsl();
+ if (isset($ssl["mode"])) {
+ $dsn .= " sslmode='" . $ssl["mode"] . "'";
+ }
+ $this->dsn($dsn, $username, $password);
return true;
}
Adminer 4.16.0-dev:
MySQL: Fix saving bit(64) values (bug #839)
PostgreSQL: Preserve whitespace in EXPLAIN (bug #827)
+PostgreSQL: Support SSL
SQLite: Fix altering forign keys (bug #841)
MS SQL: Foreign keys in non-default schema (bug #833)
Oracle: Include tables granted by other user
<?php
-/** Connect to MySQL using SSL
+/** Connect to MySQL or PostgreSQL using SSL
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
class AdminerLoginSsl {
/** @access protected */
var $ssl;
-
- /**
- * @param array array("key" => filename, "cert" => filename, "ca" => filename)
+
+ /**
+ * @param array MySQL: ["key" => filename, "cert" => filename, "ca" => filename], PostgresSQL: ["mode" => sslmode]
*/
function __construct($ssl) {
$this->ssl = $ssl;
}
-
+
function connectSsl() {
return $this->ssl;
}