Skip to content

Commit 4e38ef9

Browse files
committed
update to return full path to used, additional secure setting
1 parent 2992d2f commit 4e38ef9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/ez_sql_pdo.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ public static function securePDO(
104104
{
105105
if (\array_key_exists(\strtolower($vendor), \VENDOR)
106106
&& (! \file_exists($path.$cert) || ! \file_exists($path.$key)))
107-
ezQuery::createCertificate();
107+
$path = ezQuery::createCertificate();
108+
elseif ($path == '.'.\_DS) {
109+
$ssl_path = \getcwd();
110+
$path = \preg_replace('/\\\/', \_DS, $ssl_path). \_DS;
111+
}
108112

109113
if (($vendor == 'pgsql') || ($vendor == 'postgresql')) {
110114
self::$secure = "sslmode=require;sslcert=".$path.$cert.";sslkey=".$path.$key.";sslrootcert=".$path.$ca.";";
@@ -114,7 +118,9 @@ public static function securePDO(
114118
\PDO::MYSQL_ATTR_SSL_KEY => $path.$key,
115119
\PDO::MYSQL_ATTR_SSL_CERT => $path.$cert,
116120
\PDO::MYSQL_ATTR_SSL_CA => $path.$ca,
117-
\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
121+
\PDO::MYSQL_ATTR_SSL_CAPATH => $path,
122+
\PDO::MYSQL_ATTR_SSL_CIPHER => 'DHE-RSA-AES256-SHA',
123+
\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
118124
);
119125
} elseif (($vendor == 'sqlserver') || ($vendor == 'mssql') || ($vendor == 'sqlsrv')) {
120126
self::$secure = ";Encrypt=true;TrustServerCertificate=true";

shared/ezQuery.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static function clean($string)
5353
* "emailAddress" => ''
5454
* ];
5555
*
56+
* @return string certificate path
5657
*/
5758
public static function createCertificate(
5859
string $privatekeyFile = 'certificate.key',
@@ -63,7 +64,7 @@ public static function createCertificate(
6364
array $details = ["commonName" => "localhost"]
6465
)
6566
{
66-
if (empty($ssl_path) || ! \is_dir($ssl_path)) {
67+
if (empty($ssl_path)) {
6768
$ssl_path = \getcwd();
6869
$ssl_path = \preg_replace('/\\\/', \_DS, $ssl_path). \_DS;
6970
} else
@@ -88,6 +89,8 @@ public static function createCertificate(
8889

8990
// Create a signing request file
9091
\openssl_csr_export_to_file($csr, $ssl_path.$signingFile);
92+
93+
return $ssl_path;
9194
}
9295

9396
/**

0 commit comments

Comments
 (0)