-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(config.inc.php/docker-entrypoint.sh,dockerfile,helpers.php): Move…
… TLS logic from entrypoint to php configuration files
- Loading branch information
1 parent
6214417
commit b78da1f
Showing
4 changed files
with
88 additions
and
64 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
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,43 @@ | ||
<?php | ||
|
||
class SslFileGenerationException extends Exception {} | ||
|
||
define('OUTPUT_DIR', '/etc/phpmyadmin/ssl'); | ||
|
||
/** | ||
* Helper function to decode and save multiple SSL files from base64. | ||
* | ||
* @param string $base64_string The base64 encoded string containing multiple SSL 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 SSL file names. | ||
* @param string $extension The file extension to use for the generated SSL files. | ||
* @return string A comma-separated list of paths to the generated SSL files. | ||
*/ | ||
function decodeAndSaveSslFiles($base64_string, $prefix, $extension) { | ||
// Ensure the output directory exists | ||
if (!is_dir(OUTPUT_DIR)) { | ||
mkdir(OUTPUT_DIR, 0755, true); | ||
} | ||
|
||
// Split the base64 string into an array of files | ||
$files = strpos($base64_string, ',') !== false ? explode(',', $base64_string) : [$base64_string]; | ||
$counter = 1; | ||
$ssl_files = []; | ||
|
||
// Process each file | ||
foreach ($files as $file) { | ||
$output_file = OUTPUT_DIR . "/pma-ssl-$prefix-$counter.$extension"; | ||
|
||
// Write the decoded file to the output directory | ||
if (file_put_contents($output_file, base64_decode($file)) === false) { | ||
throw new SslFileGenerationException("Failed to write to $output_file"); | ||
} | ||
|
||
// Add the output file path to the list | ||
$ssl_files[] = $output_file; | ||
$counter++; | ||
} | ||
|
||
// Return a comma-separated list of the generated file paths | ||
return implode(',', $ssl_files); | ||
} |