hypux(hypux)  能否提供些资料
谢谢你了

解决方案 »

  1.   

    我使用的证书是使用Windows证书服务颁发的整数
    有什么好办法么?
      

  2.   

    有关调用实时(JIT)调试而不是此对话框的详细信息,
    请参阅此消息的结尾。************** 异常文本 **************
    System.Net.WebException: 基础连接已经关闭: 无法与远程服务器建立信任关系。
       at System.Net.HttpWebRequest.CheckFinalStatus()
       at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at WindowsApplication4.lirenzhao.Service1.HelloWorld()
       at WindowsApplication4.Form1.button1_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ************** 已加载的程序集 **************
    mscorlib
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
    ----------------------------------------
    WindowsApplication4
        程序集版本: 1.0.1535.20785
        Win32 版本: 1.0.1535.20785
        基本代码: file:///C:/Documents%20and%20Settings/Administrator.SYNTONG/桌面/WindowsApplication4.exe
    ----------------------------------------
    System.Windows.Forms
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    ----------------------------------------
    System
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    ----------------------------------------
    System.Drawing
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    ----------------------------------------
    System.Xml
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
    ----------------------------------------
    System.Web.Services
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.web.services/1.0.5000.0__b03f5f7f11d50a3a/system.web.services.dll
    ----------------------------------------
    System.Web
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
    ----------------------------------------
    mucgylcz
        程序集版本: 0.0.0.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    ----------------------------------------
    System.resources
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.resources.dll
    ----------------------------------------
    System.Windows.Forms.resources
        程序集版本: 1.0.5000.0
        Win32 版本: 1.1.4322.573
        基本代码: file:///c:/winnt/assembly/gac/system.windows.forms.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll
    ----------------------------------------************** JIT 调试 **************
    计算机的配置文件(machine.config)的 
     system.windows.forms 节中必须设置 jitDebugging 值。
    编译应用程序时还必须启用\r\n调试。\r\n\r\n例如: \r\n\r\n<configuration>\r\n    <system.windows.forms jitDebugging="true" />\r\n</configuration>\r\n\r\n启用 JIT 调试后,任何未处理的异常\r\n都将被发送到此计算机上注册的 JIT 调试器,\r\n而不是由此对话框处理。\r\n上面是引发的异常,但是我在自己的机器上没有问题证书是使用Windows证书服务颁发的整数
      

  3.   

    lirenzhao.Service1 s = new lirenzhao.Service1("https://lirenzhao/WebService1/Service1.asmx");
    X509Certificate x509 = X509Certificate.CreateFromCertFile(@"c:\user.cer");
    s.ClientCertificates.Add(x509);
    this.Text = s.HelloWorld();
    使用上面方法导入证书还不成功:
    未处理的“System.Security.Cryptography.CryptographicException”类型的异常出现在 mscorlib.dll 中。其他信息: 无法将输入数据作为有效证书编码。
      

  4.   

    X509Certificate.CreateFromCertFile(@"c:\user.cer");
    的问题没了是因为证书导出的格式造成的现在还是无法建立信任连接是不是windows的证书服务产生的证书有问题
      

  5.   

    是不是因为整数是Windows证书服务颁发的原因如果是CA认证的没问题吧
      

  6.   

    我试过如果客户端是非浏览器的,则在客户端使用X509Certificate.CreateFromCertFile()方法从本地证书文件导入证书,在访问服务器时仍旧会报Access Forbidden,可使用wse2.0中的X509CertificateStore进行证书存储管理,方法如下:
    1.在客户端导入证书
    //load本地的x509证书
    X509Certificate cert = X509Certificate.CreateCertFromFile("client.cer");
    //打开本地证书存储
    String sto = X509CertificateStore.MyStore;
    X509CertificateStore store = X509CertificateStore.CurrentUserStore(sto);
    store.Open();
    //如果证书不存在则加入
    if(!store.Certificates.Contains(cert))
    {
       store.Certificates.Add(cert);
    }
    store.close();2.从本地证书存储中得到证书,并调用webservice方法
    //打开证书存储
    String sto = X509CertificateStore.MyStore;
    X509CertificateStore store = X509CertificateStore.CurrentUserStore(sto);
    store.Open();
    //根据certificate hash码得到证书
    X509CertificateCollection certcoll = store.FindCertificateByHash(certhash);
    X509Certificate cert = store.Certificates[0];
    store.close();
    String dtexpire = cert.GetExpirationDateString();
    //判断证书是否已过期
    if(DateTime.Now.ToString("yy-MM-dd HH:mm:ss").CompareTo(dtexpire) < 0)
    {
              //如果证书未过期
              try
    {
       //在request中加入证书
                localhost.WebService svc = new localhost.WebService();
       svc.ClientCertificates.Add(cert);
                //在客户端使用session
       cc = new System.Net.CookieContainer();
       svc.CookieContainer = cc;
       //在soap header中加入credential
                localhost.Credential token = new localhost.Credential();
       token.UserID = "userid";
       token.Password = "password";
       svc.CredentialValue = token;
       //调用web method
       if(svc.Login())
                {
                    textBox1.Text = "登录成功";
                }
                else
                {
                    textBox1.Text = "登录失败";
                }
    }
    catch(System.Web.Services.Protocols.SoapException ex)
    {
       textBox1.Text = ex.Code.ToString() + " " + ex.Message;
    }
    }
    else
    {
             //如果证书已过期
             textBox1.Text = "证书已过期";
    }
      

  7.   

    楼上所说的WSE2.0有下载的地方么?
      

  8.   

    http://msdn.microsoft.com/webservices/
      

  9.   

    it's free
    http://www.microsoft.com/downloads/details.aspx?familyid=21fb9b9a-c5f6-4c95-87b7-fc7ab49b3edd&displaylang=en