person-key-to-immich-import birthday json (Day-Helper-2024-05-18)
csharp_prefer_braces = true
This commit is contained in:
@ -3,11 +3,9 @@ using System.Diagnostics;
|
||||
|
||||
namespace File_Folder_Helper.ADO2024.PI2;
|
||||
|
||||
internal static partial class Helper20240728
|
||||
{
|
||||
internal static partial class Helper20240728 {
|
||||
|
||||
internal static void DownloadSslCertificates(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
internal static void DownloadSslCertificates(ILogger<Worker> logger, List<string> args) {
|
||||
string file;
|
||||
Process? process;
|
||||
string[] segments;
|
||||
@ -23,8 +21,7 @@ internal static partial class Helper20240728
|
||||
int waitForExit = int.Parse(args[5]);
|
||||
string[] subdomains = args[3].Split(',');
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
ProcessStartInfo processStartInfo = new()
|
||||
{
|
||||
ProcessStartInfo processStartInfo = new() {
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardOutput = true,
|
||||
@ -32,28 +29,29 @@ internal static partial class Helper20240728
|
||||
FileName = args[4],
|
||||
WorkingDirectory = sourceDirectory
|
||||
};
|
||||
foreach (string subdomain in subdomains)
|
||||
{
|
||||
foreach (string subdomain in subdomains) {
|
||||
argumentSegment = $"{subdomain}.{domain}:443 -servername {subdomain}.{domain}";
|
||||
processStartInfo.Arguments = $"s_client -connect {subdomain}.{domain}:443 -servername {subdomain}.{domain}";
|
||||
process = Process.Start(processStartInfo);
|
||||
if (process is null)
|
||||
if (process is null) {
|
||||
continue;
|
||||
}
|
||||
_ = process.WaitForExit(waitForExit);
|
||||
process.Kill(entireProcessTree: true);
|
||||
standardOutput = process.StandardOutput.ReadToEnd();
|
||||
if (!standardOutput.Contains(beginCertificate) || !standardOutput.Contains(endCertificate))
|
||||
{
|
||||
if (!standardOutput.Contains(beginCertificate) || !standardOutput.Contains(endCertificate)) {
|
||||
standardError = process.StandardError.ReadToEnd();
|
||||
logger.LogWarning($"Error: {subdomain}{Environment.NewLine}{standardOutput}{Environment.NewLine}{standardError}");
|
||||
continue;
|
||||
}
|
||||
segments = standardOutput.Split(beginCertificate);
|
||||
if (segments.Length != 2)
|
||||
if (segments.Length != 2) {
|
||||
break;
|
||||
}
|
||||
segments = segments[1].Split(endCertificate);
|
||||
if (segments.Length != 2)
|
||||
if (segments.Length != 2) {
|
||||
break;
|
||||
}
|
||||
lines.Add($"{logSegment} \"{store}\" {subdomain}.{domain}.cert");
|
||||
file = Path.Combine(sourceDirectory, $"{subdomain}.{domain}.cert");
|
||||
File.WriteAllText(file, $"{beginCertificate}{segments[0]}{endCertificate}{Environment.NewLine}");
|
||||
|
Reference in New Issue
Block a user