Re: Using a Java Keytool created certificate in HTTPWebRequest.ClientCertificates



Outstanding. Thanks for all your advice. I was about to post back
saying pretty exactly that.

I now have the connection working but I did the following:

(1) Created the server X509 DER certificate using OpenSSL with the CN
set to the server name (the cause of my previous
RemoteCertificateNameMismatch)
(2) Installed and configured HTTPS on the Server using this X509 DER
certificate
(3) Connected to the server via HTTP using Internet Explorer
(4) Installed the Certificate from the Server to the Personal store
(5) Ran the test C# application which loaded up all the Certificates
found in the Personal Store using

X509Store store = new X509Store(StoreName.My,
StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
foreach (X509Certificate cert in store.Certificates)
{
webRequest.ClientCertificates.Add(cert);
}


(6) Implemented the ServerCertificateValidationCallback as follows

ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback
(RemoteServerCertificateValidationCallback);
...
public static bool RemoteServerCertificateValidationCallback
(Object sender, X509Certificate certificate, X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true; // sorry, awful I know
}

(7) HTTPS calls now work at the expense of ignoring the
RemoteCertificateChainErrors.ChainStatus = "Untrusted Root" error.

Is this what have suggested. Do I not need to deal with steps 3 or 4 ?

Al


On Dec 4, 9:31 am, "Joe Kaplan"
<joseph.e.kap...@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Is your goal here to just get SSL working with the server or to also
authenticate the client with SSL client certificate auth?

If you just want an HTTPS connection to the server, you don't need to
specify anything with client certs on the client side.  You just need to get
the client to trust the server's certificate.  There are two ways to do
this:
 - Fix the chain such that the client trusts the server's certificate with
default policy, or
 - Implement a custom policy that ignores some or all of the SSL policy
errors that you don't want to fix

To fix the chain locally, the Windows client must trust the server's
certificate.  For that, the issuer must chain up to a trusted root, the
subject name must match the host name in the URL and the certificate must be
in its validity period.

If you don't want to fix the trust chain because you don't care about
proving the identity of the server and just want encryption, then you can
implement a callback that allows you to ignore SSL errors.

If you really do want client cert auth, that is likely more complex.  You'll
have to deal with the above mentioned stuff, but then you'll also need to
issue a valid client certificate to the client.  You can't use the server's
certificate on the client (unless you've created both a client and server
authentication cert, but that would be a weird PKI usage).

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"http://www.directoryprogramming.net"bigAPE"; <alex.madd...@xxxxxxxxx> wrote in message
.



Relevant Pages

  • Re: Need for encryption in WSE 3.0 if using SS-avoid man-in-middle
    ... SSL only validates you are talking to a SSL certified server; ... They can simply edit the URL the client program ... can be done by using a X.509 certificate on both ends, ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: LDP client authentication fails
    ... I got the LDP working with LDAP server under server client authentication ... I did not installed the certificate in pfx format .. ... Client cert auth won't work without that. ...
    (microsoft.public.windows.server.active_directory)
  • Re: SSL & Man In the Middle Attack
    ... >> it possible for the middle man to intercept all messages from server to me ... > server sends client a signed message along with a digital certificate. ... > client generates a random secret key, ...
    (comp.security.misc)
  • Re: activesync issue
    ... On the SBS 2003 Server open the Server Management console. ... On the "Web Server Certificate" page, choose to create a new Web server ... Install the new certificate which created in above step on mobile device: ... Access to browse the Exchange Server 2003 client after you install ...
    (microsoft.public.windows.server.sbs)
  • Re: Need for encryption in WSE 3.0 if using SS-avoid man-in-middle
    ... order to detect we are connected to the wrong server (even though its SSL ... certificate is OK and valid by Verisign); we would need a client certificate. ... this can be detected by SSL/HTTPS client in ...
    (microsoft.public.dotnet.framework.aspnet.security)