Re: HTTPS with WebResponse class

From: Drebin (tRhEeMdOrVeEbin_at_hotmail.com)
Date: 08/30/03

  • Next message: Darren Mombourquette: "Re: Enterprise Policy URL Condition"
    Date: Sat, 30 Aug 2003 01:02:49 GMT
    
    

    Egads!! BAD cross-poster - BAD!!

    Anyhow, yes - this is exactly what the problem is. You can't programatically
    specify a trust list (at least I haven't run across a way) - so even if you
    log in with that account, and add the certificate authority -
    programatically - it will still not trust that CA.

    The ONLY way I've seen this or been able to get this to work (because I
    needed to do the same thing) - is you have to get real certificates, like
    from Verisign or Thawte..

    "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
    news:u7xxlOobDHA.3896@TK2MSFTNGP11.phx.gbl...
    > Yes. i used IE before calling from my application. IE popup with a warning
    > message telling me that "certificate on the server is not the same name
    bla
    > bla. " and when i hit OK, i can view the SSL page with form.
    >
    > my .NET application cannot.
    >
    >
    > "Justin Rogers" <Justin@games4dotnet.com> wrote in message
    > news:#8bt4YnbDHA.2572@TK2MSFTNGP12.phx.gbl...
    > > Best way to test your client is see if you can do the same from IE.
    Most
    > of
    > > the System.Net classes take configuration from IE behind the scenes. If
    > it
    > > doesn't work in IE and you do get it working, make sure to close all
    > > instances of IE so the data persists before re-running the .NET
    > application.
    > > Some changes are considered dynamic and won't be written to the registry
    > > until close.
    > >
    > > Hopefully you find that IE won't connect either. I find it hard to
    > believe
    > > that .NET would have a more stringent implementation of SSL than IE.
    But
    > it
    > > is possible.
    > >
    > > --
    > > Justin Rogers
    > > DigiTec Web Consultants, LLC.
    > >
    > > "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
    > > news:ezn5SNnbDHA.1580@tk2msftngp13.phx.gbl...
    > > > Hello,
    > > >
    > > > I am having a problem with WebRequest class. I used the following code
    > to
    > > > post some data to a page and retrive back the response. It works fine
    > with
    > > > http:// connection. When i use that with https:// connection, it
    thrown
    > an
    > > > exception "The underlying connection was closed: Could not establish
    > trust
    > > > relationship with remote server.". I am using self sign certificate on
    > the
    > > > web server and the root and CA certificates are installed on the
    client
    > > > machine using the following code.
    > > >
    > > > your suggestions will be great appreciated.
    > > >
    > > > Aung
    > > >
    > > > public string postForm(string url, string postData)
    > > >
    > > > {
    > > >
    > > > string retStr="", tempStr;
    > > >
    > > > HttpWebResponse result = null;
    > > >
    > > > try
    > > >
    > > > {
    > > >
    > > > HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
    > > >
    > > > req.Method = "POST";
    > > >
    > > > req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
    .NET
    > > CLR
    > > > 1.0.3705)";
    > > >
    > > > req.ContentType = "application/x-www-form-urlencoded";
    > > >
    > > > StringBuilder UrlEncoded = new StringBuilder();
    > > >
    > > > Char[] reserved = {'?', '=', '&'};
    > > >
    > > > byte[] SomeBytes = null;
    > > >
    > > > if (postData != null)
    > > >
    > > > {
    > > >
    > > > int i=0, j;
    > > >
    > > > while(i<postData.Length)
    > > >
    > > > {
    > > >
    > > > j=postData.IndexOfAny(reserved, i);
    > > >
    > > > if (j==-1)
    > > >
    > > > {
    > > >
    > > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.Substring(i,
    > > > postData.Length-i)));
    > > >
    > > > break;
    > > >
    > > > }
    > > >
    > > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.Substring(i, j-i)));
    > > >
    > > > UrlEncoded.Append(postData.Substring(j,1));
    > > >
    > > > i = j+1;
    > > >
    > > > }
    > > >
    > > > SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
    > > >
    > > > req.ContentLength = SomeBytes.Length;
    > > >
    > > > Stream newStream = req.GetRequestStream();
    > > >
    > > > newStream.Write(SomeBytes, 0, SomeBytes.Length);
    > > >
    > > > newStream.Close();
    > > >
    > > > }
    > > >
    > > > else
    > > >
    > > > {
    > > >
    > > > req.ContentLength = 0;
    > > >
    > > > }
    > > >
    > > > result = (HttpWebResponse) req.GetResponse();
    > > >
    > > > Stream ReceiveStream = result.GetResponseStream();
    > > >
    > > > Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
    > > >
    > > > StreamReader sr = new StreamReader( ReceiveStream, encode );
    > > >
    > > > Char[] read = new Char[256];
    > > >
    > > > int count = sr.Read( read, 0, 256 );
    > > >
    > > > while (count > 0)
    > > >
    > > > {
    > > >
    > > > tempStr = new String(read, 0, count);
    > > >
    > > > retStr += tempStr;
    > > >
    > > > count = sr.Read(read, 0, 256);
    > > >
    > > > }
    > > >
    > > > retStr.Trim();
    > > >
    > > > }
    > > >
    > > > catch (Exception e)
    > > >
    > > > {
    > > >
    > > > retStr = "Error!!";
    > > >
    > > > }
    > > >
    > > > finally
    > > >
    > > > {
    > > >
    > > > if ( result != null )
    > > >
    > > > {
    > > >
    > > > result.Close();
    > > >
    > > > }
    > > >
    > > > }
    > > >
    > > > return retStr;
    > > >
    > > > }
    > > >
    > > >
    > > >
    > >
    > >
    >
    >


  • Next message: Darren Mombourquette: "Re: Enterprise Policy URL Condition"

    Relevant Pages

    • Re: Enabling guest wi-fi access w/ IAS & Cisco APs ... ?
      ... > client insisting that they could not connect because a valid ... > certificate could not be found. ... meaning that tha client computer attempts to authenticate the IAS server. ... because it does not trust the CA that issued the IAS server cert. ...
      (microsoft.public.internet.radius)
    • Re: login to Website using a SmartCard
      ... this means I've to check the certificate in ... you can specify that you accept client certificates (IE will transparently ... Context.Request.ClientCertificate.IsPresent, and if you trust the cert, ... User also have a smart card that permit ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: How to automate this ... ?
      ... client unless you established trust to that server (that's basically what ... Domain membership and Group Policy is -- the server trusts the external ... Purchase a certificate from an established Certificate Registrar. ... make the IE to trust my own Microsoft CA? ...
      (microsoft.public.inetserver.iis.security)
    • Re: Proposal for a new PKI model (At least I hope its new)
      ... That is say I trust Paul Rubin's public key. ... two basic reasons for the SSL server domain name certificate: ... certificates have to check with the domain name infrastructure to see ... CA/PKI industry is that public keys be registered with the domain name ...
      (sci.crypt)
    • Re: SMTP and IMAP SSL Certificates
      ... Add the CA as a trusted CA on the client side. ... Security Warning" window that states "The server you are connected to ... is using a security certificate that could not be verified. ... Is there anyway to get the CA server to trust this certificate? ...
      (microsoft.public.exchange.admin)