Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally found a way to make this work.</p> <p>First, theses posts helped me get on the right track : <a href="http://directoryprogramming.net/forums/thread/788.aspx" rel="nofollow noreferrer">http://directoryprogramming.net/forums/thread/788.aspx</a></p> <p>Second, I got a compiled dll of the Novell LDAP Library and used the Mono.Security.Dll.</p> <p>The solution: </p> <p>I added this function to the code</p> <pre><code>// This is the Callback handler - after "Binding" this is called public bool MySSLHandler(Syscert.X509Certificate certificate, int[] certificateErrors) { X509Store store = null; X509Stores stores = X509StoreManager.LocalMachine; store = stores.TrustedRoot; //Import the details of the certificate from the server. X509Certificate x509 = null; X509CertificateCollection coll = new X509CertificateCollection(); byte[] data = certificate.GetRawCertData(); if (data != null) x509 = new X509Certificate(data); //List the details of the Server //if (bindCount == 1) //{ Response.Write("&lt;b&gt;&lt;u&gt;CERTIFICATE DETAILS:&lt;/b&gt;&lt;/u&gt; &lt;br&gt;"); Response.Write(" Self Signed = " + x509.IsSelfSigned + " X.509 version=" + x509.Version + "&lt;br&gt;"); Response.Write(" Serial Number: " + CryptoConvert.ToHex(x509.SerialNumber) + "&lt;br&gt;"); Response.Write(" Issuer Name: " + x509.IssuerName.ToString() + "&lt;br&gt;"); Response.Write(" Subject Name: " + x509.SubjectName.ToString() + "&lt;br&gt;"); Response.Write(" Valid From: " + x509.ValidFrom.ToString() + "&lt;br&gt;"); Response.Write(" Valid Until: " + x509.ValidUntil.ToString() + "&lt;br&gt;"); Response.Write(" Unique Hash: " + CryptoConvert.ToHex(x509.Hash).ToString() + "&lt;br&gt;"); // } bHowToProceed = true; if (bHowToProceed == true) { //Add the certificate to the store. This is \Documents and Settings\program data\.mono. . . if (x509 != null) coll.Add(x509); store.Import(x509); if (bindCount == 1) removeFlag = true; } if (bHowToProceed == false) { //Remove the certificate added from the store. if (removeFlag == true &amp;&amp; bindCount &gt; 1) { foreach (X509Certificate xt509 in store.Certificates) { if (CryptoConvert.ToHex(xt509.Hash) == CryptoConvert.ToHex(x509.Hash)) { store.Remove(x509); } } } Response.Write("SSL Bind Failed."); } return bHowToProceed; } </code></pre> <p>And i used it in the binding process</p> <pre><code>// Create Connection LdapConnection conn = new LdapConnection(); conn.SecureSocketLayer = true; Response.Write("Connecting to:" + ldapHost); conn.UserDefinedServerCertValidationDelegate += new CertificateValidationCallback(MySSLHandler); if (bHowToProceed == false) conn.Disconnect(); if (bHowToProceed == true) { conn.Connect(ldapHost, ldapPort); conn.Bind(loginDN, password); Response.Write(" SSL Bind Successfull "); conn.Disconnect(); } quit = false; </code></pre> <p>The key elements are using the SSL Handler to dynamically obtain the Certificate, and using X509StoreManager.LocalMachine so that when the website is running its able to save and fetch the certificates.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload