CRL(証明書失効リスト)キャッシュをすぐに無効にして、クライアントにCRLを再度ダウンロードさせる方法はありますか?
コマンドライン「certutil.exe」を使用せずに、C#でこれを実現したいと思います。
さらに良いのは、無効化時間を設定できることです(UtcNow + 12時間など)
CRL(証明書失効リスト)キャッシュをすぐに無効にして、クライアントにCRLを再度ダウンロードさせる方法はありますか?
コマンドライン「certutil.exe」を使用せずに、C#でこれを実現したいと思います。
さらに良いのは、無効化時間を設定できることです(UtcNow + 12時間など)
私はすでにそのようなソリューションを実装しています。スケジューラの設定に応じて、クライアント マシンの CRL キャッシュを x 時間ごとに更新します。ここで CRL について読むことができます: http://social.technet.microsoft.com/wiki/contents/articles/4954.certificate-status-and-revocation-checking.aspx
CRL キャッシュは、クライアント マシンの特別なフォルダーに保存され、Metadata フォルダーと Content フォルダーに保存された 2 つのファイルで構成されます。これらのフォルダーは「C:\Documents and Settings{ユーザー名}\Application Data\Microsoft\CryptnetUrlCache」に配置され、コンピューターごとのキャッシュの場所は「%WINDIR%\System32\config\SystemProfile\Application Data\Microsoft\CryptnetUrlCache」です。 . Cahce ファイルは、CRL url の MD5 ハッシュ サムで名前が付けられます。フォルダー「メタデータ」内のファイルには、いくつかの定数データ、最終更新日、CRL URL、CRL ファイル サイズなどが含まれています。また、「Content」フォルダ内のファイルはCRLファイルそのもので、「Metadata」のファイルと同じ名前です。メタ ファイルを解析し、無効かどうかを確認し、CRL URL で新しい CRL ファイルを読み込み、「コンテンツ」フォルダーに配置して、メタデータ ファイルを再構築します。これらの目的で BouncyCastle ライブラリを使用します。
使用したくないことはわかっていますcertutil.exe
が、この方法を使用すると、cmd ウィンドウが表示されずにアプリケーションで実行できます。
public bool ClearCRLCache()
{
var pw = new ProcessWrapper();
var result = pw.Start("certutil.exe", "-urlcache * delete");
// -2147024637 is the exitcode when the urlcache is empty
return (result == 0 || result == -2147024637);
}
クラス ProcessWrapper:
public class ProcessWrapper
{
/// <summary>
/// Output from stderr
/// </summary>
public string StdErr { get; private set; }
/// <summary>
/// Output from stdout
/// </summary>
public string StdOut { get; private set; }
/// <summary>
/// Starts a process
/// </summary>
/// <param name="command">Executable filename</param>
/// <returns>Process exitcode</returns>
public int Start(string command)
{
return Start(command, "");
}
/// <summary>
/// Starts a process with commandline arguments
/// </summary>
/// <param name="command">Executable filename</param>
/// <param name="arguments">Commanline arguments for the process</param>
/// <returns>Process exitcode</returns>
public int Start(string command, string arguments)
{
return Start(command, arguments, "");
}
/// <summary>
/// Starts a process with commandline arguments and working directory
/// </summary>
/// <param name="command">Executable filename</param>
/// <param name="arguments">Commanline arguments for the process</param>
/// <param name="workingDirectory">Working directory for the process</param>
/// <returns>Process exitcode</returns>
public int Start(string command, string arguments, string workingDirectory)
{
StdErr = "";
StdOut = "";
var proc = new Process();
proc.StartInfo.FileName = command;
proc.StartInfo.Arguments = arguments;
proc.StartInfo.WorkingDirectory = workingDirectory;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.EnableRaisingEvents = true;
proc.StartInfo.CreateNoWindow = true;
// Write messages from stderr to StdErr property
proc.ErrorDataReceived += (sender, e) =>
{
StdErr += e.Data + Environment.NewLine;
};
// Write messages from stdout to StdOut property
proc.OutputDataReceived += (sender, e) =>
{
StdOut += e.Data + Environment.NewLine;
};
proc.Start();
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
proc.WaitForExit();
return proc.ExitCode;
}
}