mirror of
https://github.com/vrana/adminer.git
synced 2025-08-30 09:39:51 +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:
@@ -24,11 +24,26 @@ if (isset($_GET["mssql"])) {
|
|||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
global $adminer;
|
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();
|
$db = $adminer->database();
|
||||||
$connection_info = array("UID" => $username, "PWD" => $password, "CharacterSet" => "UTF-8");
|
|
||||||
if ($db != "") {
|
if ($db != "") {
|
||||||
$connection_info["Database"] = $db;
|
$connection_info["Database"] = $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_link = @sqlsrv_connect(preg_replace('~:~', ',', $server), $connection_info);
|
$this->_link = @sqlsrv_connect(preg_replace('~:~', ',', $server), $connection_info);
|
||||||
if ($this->_link) {
|
if ($this->_link) {
|
||||||
$info = sqlsrv_server_info($this->_link);
|
$info = sqlsrv_server_info($this->_link);
|
||||||
@@ -36,6 +51,7 @@ if (isset($_GET["mssql"])) {
|
|||||||
} else {
|
} else {
|
||||||
$this->_get_error();
|
$this->_get_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) $this->_link;
|
return (bool) $this->_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,8 +29,8 @@ function adminer_object() {
|
|||||||
new AdminerTranslation,
|
new AdminerTranslation,
|
||||||
new AdminerForeignSystem,
|
new AdminerForeignSystem,
|
||||||
new AdminerEnumOption,
|
new AdminerEnumOption,
|
||||||
new AdminerTablesFilter,
|
|
||||||
new AdminerEditForeign,
|
new AdminerEditForeign,
|
||||||
|
new AdminerLoginSsl(["TrustServerCertificate" => true]),
|
||||||
);
|
);
|
||||||
|
|
||||||
/* It is possible to combine customization and plugins:
|
/* It is possible to combine customization and plugins:
|
||||||
|
@@ -10,11 +10,12 @@
|
|||||||
*/
|
*/
|
||||||
class AdminerLoginSsl
|
class AdminerLoginSsl
|
||||||
{
|
{
|
||||||
private var $ssl;
|
private $ssl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL: ["key" => filename, "cert" => filename, "ca" => filename]
|
* MySQL: ["key" => filename, "cert" => filename, "ca" => filename]
|
||||||
* PostgresSQL: ["mode" => sslmode] (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE)
|
* 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)
|
function __construct(array $ssl)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user