Example #1
0
 /// <summary>
 /// Find a server certificate in the given store.
 /// </summary>
 /// <param name="store"></param>
 /// <returns></returns>
 public static Certificate FindServerCert(CertificateStore store)
 {
     // return store.FindCertificate(new string[] {OID_PKIX_KP_SERVER_AUTH});
     return store.FindCertificateByUsage(new string[] {OID_PKIX_KP_SERVER_AUTH});
 }
Example #2
0
 /// <summary>
 /// Find a client certificate in the given store.
 /// </summary>
 /// <param name="store"></param>
 /// <returns></returns>
 public static Certificate FindClientCert(CertificateStore store)
 {
     //return store.FindCertificate(new string[] {OID_PKIX_KP_CLIENT_AUTH});
     return store.FindCertificateByUsage(new string[] {OID_PKIX_KP_CLIENT_AUTH});
 }
Example #3
0
 /// <summary>
 /// Asks the user to specify a server certificate, stored in a certificate store.
 /// </summary>
 /// <returns>A server certificate.</returns>
 private Certificate GetStoreCert()
 {
     try {
         Console.WriteLine("Enter the name of the store (for instance \"MY\", without the quotes):");
         // open the certificate store specified by the user
         CertificateStore cs = new CertificateStore(Console.ReadLine());
         // find a certificate that is suited for server authentication
         Certificate ret = cs.FindCertificateByUsage(new string[] {"1.3.6.1.5.5.7.3.1"});
         if (ret == null)
             Console.WriteLine("The certificate file does not contain a server authentication certificate.");
         return ret;
     } catch {
         Console.WriteLine("An error occurs while opening the specified store.");
         return null;
     }
 }