1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-18 20:31:19 +02:00

MSSQL: Allow to set Encrypt and TrustServerCertificate with AdminerLoginSsl plugin (issue #5)

https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax#use-trustservercertificate
This commit is contained in:
Peter Knut
2024-11-10 21:57:12 +01:00
committed by Jakub Vrana
parent a685d414ad
commit 5eb3446908
3 changed files with 17 additions and 7 deletions

View File

@@ -24,8 +24,15 @@ if (isset($_GET["mssql"])) {
function connect($server, $username, $password) { function connect($server, $username, $password) {
global $adminer; global $adminer;
$db = $adminer->database();
$connection_info = array("UID" => $username, "PWD" => $password, "CharacterSet" => "UTF-8"); $connection_info = array("UID" => $username, "PWD" => $password, "CharacterSet" => "UTF-8");
$ssl = $adminer->connectSsl();
if (isset($ssl["Encrypt"])) {
$connection_info["Encrypt"] = $ssl["Encrypt"];
}
if (isset($ssl["TrustServerCertificate"])) {
$connection_info["TrustServerCertificate"] = $ssl["TrustServerCertificate"];
}
$db = $adminer->database();
if ($db != "") { if ($db != "") {
$connection_info["Database"] = $db; $connection_info["Database"] = $db;
} }

View File

@@ -2,15 +2,15 @@
function adminer_object() { function adminer_object() {
// required to run any plugin // required to run any plugin
include_once "../plugins/plugin.php"; include_once "../plugins/plugin.php";
// autoloader // autoloader
foreach (glob("../plugins/*.php") as $filename) { foreach (glob("../plugins/*.php") as $filename) {
include_once $filename; include_once $filename;
} }
// enable extra drivers just by including them // enable extra drivers just by including them
//~ include "../plugins/drivers/simpledb.php"; //~ include "../plugins/drivers/simpledb.php";
$plugins = array( $plugins = array(
// specify enabled plugins here // specify enabled plugins here
new AdminerDatabaseHide(array('information_schema')), new AdminerDatabaseHide(array('information_schema')),
@@ -32,13 +32,13 @@ function adminer_object() {
new AdminerTablesFilter, new AdminerTablesFilter,
new AdminerEditForeign, new AdminerEditForeign,
); );
/* It is possible to combine customization and plugins: /* It is possible to combine customization and plugins:
class AdminerCustomization extends AdminerPlugin { class AdminerCustomization extends AdminerPlugin {
} }
return new AdminerCustomization($plugins); return new AdminerCustomization($plugins);
*/ */
return new AdminerPlugin($plugins); return new AdminerPlugin($plugins);
} }

View File

@@ -11,7 +11,10 @@ class AdminerLoginSsl {
var $ssl; var $ssl;
/** /**
* @param array MySQL: ["key" => filename, "cert" => filename, "ca" => filename, "verify" => bool], PostgresSQL: ["mode" => sslmode] * @param array
* MySQL: ["key" => filename, "cert" => filename, "ca" => filename, "verify" => bool]
* PostgresSQL: ["mode" => sslmode] (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE)
* MSSQL: ["Encrypt" => true, "TrustServerCertificate" => true] (https://learn.microsoft.com/en-us/sql/connect/php/connection-options)
*/ */
function __construct($ssl) { function __construct($ssl) {
$this->ssl = $ssl; $this->ssl = $ssl;