1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-30 01:30:12 +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
parent 55e0c348b8
commit 99f4c22c72
3 changed files with 25 additions and 8 deletions

View File

@@ -24,11 +24,26 @@ if (isset($_GET["mssql"])) {
function connect($server, $username, $password) {
global $adminer;
$connection_info = [
"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();
$connection_info = array("UID" => $username, "PWD" => $password, "CharacterSet" => "UTF-8");
if ($db != "") {
$connection_info["Database"] = $db;
}
$this->_link = @sqlsrv_connect(preg_replace('~:~', ',', $server), $connection_info);
if ($this->_link) {
$info = sqlsrv_server_info($this->_link);
@@ -36,6 +51,7 @@ if (isset($_GET["mssql"])) {
} else {
$this->_get_error();
}
return (bool) $this->_link;
}

View File

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

View File

@@ -10,11 +10,12 @@
*/
class AdminerLoginSsl
{
private var $ssl;
private $ssl;
/**
* MySQL: ["key" => filename, "cert" => filename, "ca" => filename]
* 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(array $ssl)
{