|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
RE: Web service consuming errordid you find an answer to this problem? I am having a similiar issue. I have a VB.NET program that passes an X509 certificate to a third party, sends an XML request and receives an XML response. It is working fine on computers that have v1.1.4322.573 of the Framework installed. It does not work on computers that have SP1 (v1.1.4322.2032) for the .NET Framework installed on them. On these computers (with v1.1.4322.2032), I get the same error as you do. I have not been able to find the hot fix for this yet. Just wondering what version of the .NET Framework are you trying to use? Show quoteHide quote "Pragati B via .NET 247" wrote: > Hi All, > > I am new to web service consuming... and so need some help and advice. > > We need to consume a web service (by a third party vendor), to get some information. We are using C# on .NET 1.1 and WSE 1.0SP1. The service uses https://. We also need a two-way certification for accessing the data. I have imported the certificate (provided by the vendor) under my personal settings. > > Now the problem lies in getting the connection to the service. I am just testing the connectivity by calling their "sayHello()" function. I am doing this in a console based program (for ease of coding). > > Below please find my code to access the web service. I am getting the error - "System.Net.WebException: The underlying connection was closed: Could not establish secure channel for SSL/TLS. -->System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted". > > I have tried the various options listed in the forums. But no success as of now. > > Grateful, if somebody can point me to the correct direction I need to look for getting to the root of this issue. Is there any checklist which I can use to eliminate the problems? > > Thanks a lot for the help. > > -------------------------------- > From: Pragati B > > ********************************************************* > using System; > using System.Net; > using System.Reflection; > using Microsoft.Web.Services; > using Microsoft.Web.Services.Security; > using Microsoft.Web.Services.Security.X509; > using System.Security.Cryptography; > > > namespace Client > { > /// <summary> > /// Class for implementing the security policy, so that all the certificates > /// can be validated > /// </summary> > class CertPolicy: ICertificatePolicy > { > public bool CheckValidationResult(System.Net.ServicePoint srvPoint, > System.Security.Cryptography.X509Certificates.X509Certificate Certificate, > System.Net.WebRequest request, int certificateProblem) > { > Console.WriteLine(Certificate.GetName()); > return true; > } > } > > /// <summary> > /// Class created to keep the connection alive > /// </summary> > public class SubService : WebReference.WebServiceService > { > private static PropertyInfo requestPropertyInfo = null; > > public SubService(){} > > protected override System.Net.WebRequest GetWebRequest(Uri uri) > { > WebRequest request = base.GetWebRequest(uri); > > if (requestPropertyInfo==null) > // Retrieve property info and store it in a static member for optimizing future use > requestPropertyInfo = request.GetType().GetProperty("Request"); > > // Retrieve underlying web request > HttpWebRequest webRequest = (HttpWebRequest)requestPropertyInfo.GetValue(request, null); > > // Setting KeepAlive > webRequest.KeepAlive = false; > return request; > } > } > > /// <summary> > /// Main class accessing the service. > /// </summary> > class AccessClient > { > /// <summary> > /// To obtain the client certificate > /// </summary> > /// <returns></returns> > private static X509SecurityToken GetSecurityToken() > { > X509SecurityToken securityToken=null; > X509Certificate cert12; > X509CertificateStore store = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore); > > bool open = store.OpenRead(); > try > { > X509CertificateCollection certs = store.Certificates; > string strcert = null; > foreach(X509Certificate cert1 in certs) > { > strcert = Convert.ToBase64String(cert1.GetKeyIdentifier()); > } > byte[] keyIda = Convert.FromBase64String(strcert); > X509CertificateCollection matchingCerts = store.FindCertificateByKeyIdentifier(keyIda); > cert12 = matchingCerts[0];securityToken = new X509SecurityToken(cert12); > } > catch(Exception ex) > { > Console.WriteLine(ex); > } > return securityToken; > } > > /// <summary> > /// The main entry point for the application. > /// </summary> > [STAThread] > static void Main(string[] args) > { > try > { > Client.WebSubService service > = new Client.SubService(); > service.CookieContainer = new System.Net.CookieContainer(); > service.RequestSoapContext.Path.MustUnderstand = false; > > System.Net.ServicePointManager.CertificatePolicy = new CertPolicy(); > > UsernameToken tkn = new UsernameToken("user", "pwd", PasswordOption.SendHashed); > service.RequestSoapContext.Security.Tokens.Add(tkn); > service.RequestSoapContext.Security.Elements.Add(new Signature(tkn)); > X509SecurityToken signatureToken = GetSecurityToken(); > if(signatureToken == null) > { > Console.WriteLine("Error in getting the certificate token."); > } > else > { > SoapContext requestContext = service.RequestSoapContext; > requestContext.Timestamp.Ttl = 60000; > requestContext.Security.Tokens.Add(signatureToken); > requestContext.Security.Elements.Add(new Signature(signatureToken)); > > Console.WriteLine("Saying Hello..."); > Console.WriteLine(service.sayHello()); // <<<=========== exception comes here > } > } > catch(System.Exception ex) > { > Console.WriteLine(ex); > } > } > } > } > > ----------------------- > Posted by a user from .NET 247 (http://www.dotnet247.com/) > > <Id>T0AXnYEnZkeO9wCmPX+gRg==</Id> >
WindowsIdentity vs User.Identity ??
EventLogPermission via caspol.exe declarative security and impersonation Code Source Security How to share a Principal within a ThreadPool ? Authenticate domain and local users Strong-Name Assembly calling WebService CredUIConfirmCredentials behaves unexpectedly RSA to PKCS#8 Walking Active Directory |
|||||||||||||||||||||||