-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mutual TLS (mTLS) support for remote database connections in PhpM…
…yAdmin (#448) Add mutual TLS (mTLS) support for remote database connections in PhpMyAdmin Pull-request: #448 Signed-off-by: lordrobincbz <[email protected]> Co-authored-by: William Desportes <[email protected]>
- Loading branch information
1 parent
12b0f34
commit e1fe998
Showing
16 changed files
with
534 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ __pycache__ | |
.pytest_cache | ||
.vscode | ||
.history | ||
.venv | ||
.venv | ||
testing/*.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Helper function to decode and save multiple SSL files from base64. | ||
* | ||
* @param string $base64FilesContents The base64 encoded string containing multiple files separated by commas. | ||
* If no commas are present, the entire string is treated as a single file. | ||
* @param string $prefix The prefix to use for the generated file names. | ||
* @param string $extension The file extension to use for the generated files. | ||
* @param string $storageFolder The folder where to store the generated files. | ||
* | ||
* @return string A comma-separated list of paths to the generated files. | ||
*/ | ||
function decodeBase64AndSaveFiles(string $base64FilesContents, string $prefix, string $extension, string $storageFolder): string | ||
{ | ||
// Ensure the output directory exists | ||
if (! is_dir($storageFolder)) { | ||
mkdir($storageFolder, 0755, true); | ||
} | ||
|
||
// Split the base64 string into an array of files | ||
$base64FilesContents = explode(',', trim($base64FilesContents)); | ||
$counter = 1; | ||
$outputFiles = []; | ||
|
||
// Process each file | ||
foreach ($base64FilesContents as $base64FileContent) { | ||
$outputFile = $storageFolder . '/' . $prefix . '-' . $counter . '.' . $extension; | ||
|
||
$fileContent = base64_decode($base64FileContent, true); | ||
if ($fileContent === false) { | ||
echo 'Failed to decode: ' . $base64FileContent; | ||
exit(1); | ||
} | ||
|
||
// Write the decoded file to the output directory | ||
if (file_put_contents($outputFile, $fileContent) === false) { | ||
echo 'Failed to write to ' . $outputFile; | ||
exit(1); | ||
} | ||
|
||
// Add the output file path to the list | ||
$outputFiles[] = $outputFile; | ||
$counter++; | ||
} | ||
|
||
// Return a comma-separated list of the generated file paths | ||
return implode(',', $outputFiles); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.