2012-05-09 12 views
7

क्या सीआरएल (सर्टिफिकेट रिवोकेशन लिस्ट) कैश को तत्काल अमान्य करने का कोई तरीका है जिससे ग्राहक फिर से सीआरएल डाउनलोड कर सकते हैं?अमान्य सीआरएल कैश

मैं इसे कमांड लाइन 'certutil.exe' का उपयोग किए बिना सी # में प्राप्त करना चाहता हूं।

और भी बेहतर अमान्यकरण समय निर्धारित करने में सक्षम होना होगा (जैसे UtcNow + 12hours)

+0

यदि आपकी समस्या केवल cmd विंडो है, तो आप एक दृश्य कमांड लाइन विंडो के बिना एक प्रक्रिया (certutil) चला सकते हैं। – Ondra

उत्तर

0

मुझे पता है तुम 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; 
    } 
} 
1

मैं पहले से ही, इस तरह के समाधान को लागू यह ग्राहकों मशीन पर सीआरएल कैश को अद्यतन हर एक्स घंटे, अनुसूचक सेटिंग्स के आधार पर। आप सीआरएल के बारे में यहाँ पढ़ सकते हैं: http://social.technet.microsoft.com/wiki/contents/articles/4954.certificate-status-and-revocation-checking.aspx

सीआरएल कैश विशेष फ़ोल्डर में क्लाइंट मशीन पर संग्रहीत किया जाता है और मेटाडाटा और सामग्री फ़ोल्डर में संगृहीत दो फ़ाइलों से मिलकर बनता है। इन फ़ोल्डर्स को "सी: \ दस्तावेज़ और सेटिंग्स {उपयोगकर्ता नाम} \ अनुप्रयोग डेटा \ Microsoft \ CryptnetUrlCache" में रखा गया है और प्रति-मशीन कैश स्थान "% WINDIR% \ System32 \ config \ SystemProfile \ Application Data \ Microsoft \ CryptnetUrlCache" । कैस फाइलों का नाम सीडीएल यूआरएल के एमडी 5 हैश योग में रखा गया है। फ़ोल्डर "मेटाडाटा" में फ़ाइल में कुछ स्थिर डेटा, अंतिम अद्यतन की तारीख, सीआरएल यूआरएल, सीआरएल फ़ाइल आकार और अन्य शामिल हैं। और "सामग्री" फ़ोल्डर में फ़ाइल सीआरएल फ़ाइल स्वयं है और "मेटाडाटा" से फ़ाइल के समान नाम है। मैं मेटा फ़ाइल को पार्स करता हूं, जांचता हूं कि यह अमान्य है और सीआरएल यूआरएल द्वारा नई सीआरएल फ़ाइल लोड करें, इसे "सामग्री" फ़ोल्डर में रखें और मेटाडेटा फ़ाइल का पुनर्निर्माण करें। मैं इन उद्देश्यों के लिए BouncyCastle लाइब्रेरी का उपयोग करता हूं। शेड्यूलिंग लाइब्रेरी के रूप में मैं Quartz.Net का उपयोग करता हूं।

संबंधित मुद्दे