Added HostNameInCertificate (#1350)

This commit is contained in:
Jenny Tam 2022-01-05 08:59:48 -08:00 committed by GitHub
parent e2dd5137a4
commit 34e20db69d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 0 deletions

View file

@ -69,6 +69,7 @@ const char TransactionIsolation[] = "TransactionIsolation";
const char TransparentNetworkIPResolution[] = "TransparentNetworkIPResolution";
const char WSID[] = "WSID";
const char ComputePool[] = "ComputePool";
const char HostNameInCertificate[] = "HostNameInCertificate";
}
@ -478,6 +479,15 @@ const connection_option PDO_CONN_OPTS[] = {
CONN_ATTR_STRING,
conn_str_append_func::func
},
{
PDOConnOptionNames::HostNameInCertificate,
sizeof(PDOConnOptionNames::HostNameInCertificate),
SQLSRV_CONN_OPTION_HOSTNAME_IN_CERT,
ODBCConnOptions::HostNameInCertificate,
sizeof(ODBCConnOptions::HostNameInCertificate),
CONN_ATTR_STRING,
conn_str_append_func::func
},
{ NULL, 0, SQLSRV_CONN_OPTION_INVALID, NULL, 0 , CONN_ATTR_INVALID, NULL }, //terminate the table
};

View file

@ -1168,6 +1168,7 @@ const char UID[] = "UID";
const char PWD[] = "PWD";
const char SERVER[] = "Server";
const char ComputePool[] = "ComputePool";
const char HostNameInCertificate[] = "HostNameInCertificate";
}
@ -1206,6 +1207,7 @@ enum SQLSRV_CONN_OPTIONS {
SQLSRV_CONN_OPTION_CONN_RETRY_COUNT,
SQLSRV_CONN_OPTION_CONN_RETRY_INTERVAL,
SQLSRV_CONN_OPTION_COMPUTE_POOL,
SQLSRV_CONN_OPTION_HOSTNAME_IN_CERT,
// Driver specific connection options
SQLSRV_CONN_OPTION_DRIVER_SPECIFIC = 1000,

View file

@ -259,6 +259,7 @@ const char TransparentNetworkIPResolution[] = "TransparentNetworkIPResolution";
const char UID[] = "UID";
const char WSID[] = "WSID";
const char ComputePool[] = "ComputePool";
const char HostNameInCertificate[] = "HostNameInCertificate";
}
@ -613,6 +614,15 @@ const connection_option SS_CONN_OPTS[] = {
CONN_ATTR_STRING,
conn_str_append_func::func
},
{
SSConnOptionNames::HostNameInCertificate,
sizeof(SSConnOptionNames::HostNameInCertificate),
SQLSRV_CONN_OPTION_HOSTNAME_IN_CERT,
ODBCConnOptions::HostNameInCertificate,
sizeof(ODBCConnOptions::HostNameInCertificate),
CONN_ATTR_STRING,
conn_str_append_func::func
},
{ NULL, 0, SQLSRV_CONN_OPTION_INVALID, NULL, 0 , CONN_ATTR_INVALID, NULL }, //terminate the table
};

View file

@ -0,0 +1,23 @@
--TEST--
Test HostNameInCertificate keyword
--DESCRIPTION--
This test does not test if any connection is successful but mainly test if the HostNameInCertificate keyword is recognized.
--SKIPIF--
<?php require('skipif.inc');?>
--FILE--
<?php
require_once 'MsSetup.inc';
try {
$connectionInfo = "HostNameInCertificate = dummy;";
$conn1 = new PDO("sqlsrv:server = $server; $connectionInfo", $uid, $pwd);
} catch (PDOException $e) {
// do nothing
}
unset($conn1);
echo 'Done' . PHP_EOL;
?>
--EXPECT--
Done

View file

@ -0,0 +1,21 @@
--TEST--
Test HostNameInCertificate keyword
--DESCRIPTION--
This test does not test if any connection is successful but mainly test if the HostNameInCertificate keyword is recognized.
--SKIPIF--
<?php require('skipif.inc');?>
--FILE--
<?php
require_once 'MsSetup.inc';
$connectionOptions = array('HostNameInCertificate' => 'dummy');
$conn = sqlsrv_connect($server, $connectionOptions);
if ($conn != false) {
sqlsrv_close($conn);
}
echo 'Done' . PHP_EOL;
?>
--EXPECT--
Done