在WinXP+sp2下的IE有一个选项:“清除SSL状态”,如何编程实现它SslEmptyCacheA 这个函数试过了 没用

解决方案 »

  1.   

    是删除SSL状态,不是清除历史记录。
      

  2.   

    晕,以为是VB
    SslEmptyCacheA(NULL,0)This function has no associated import library. You must use the LoadLibrary and GetProcAddress functions to dynamically link to Schannel.dll.
      

  3.   


    请问0&是什么?
    我用了SslEmptyCacheA(0,0)  SslEmptyCacheA(NULL,NULL)
    都不行
      

  4.   

    调用SslEmptyCache成功吗?
    1、如果失败,报什么错?是不是参数pszTargetName有问题。
    2、如果成功,尝试再调用一次SslEmptyCache,看结果如何?
      

  5.   

    c#的例子:using System;
    using System.Runtime.InteropServices;namespace Demo
    {
        public class Ssl
        {
            [DllImport("kernel32.dll")]
            internal static extern IntPtr LoadLibrary(String dllname);        [DllImport("kernel32.dll")]
            internal static extern IntPtr GetProcAddress(IntPtr hModule, String procname);        internal delegate bool SslEmptyCacheHelper(IntPtr targetName, int flags);        /// <summary>
            /// UNICODE版
            /// </summary>
            /// <returns></returns>
            public bool SslEmptyCacheW()
            {
                IntPtr schannel = LoadLibrary("Schannel.dll");
                IntPtr procaddr = GetProcAddress(schannel, "SslEmptyCacheW");
                SslEmptyCacheHelper helper = (SslEmptyCacheHelper)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SslEmptyCacheHelper));
                return helper(IntPtr.Zero, 0);
            }        /// <summary>
            /// ANSI版
            /// </summary>
            /// <returns></returns>
            public bool SslEmptyCacheA()
            {
                IntPtr schannel = LoadLibrary("Schannel.dll");
                IntPtr procaddr = GetProcAddress(schannel, "SslEmptyCacheA");
                SslEmptyCacheHelper helper = (SslEmptyCacheHelper)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SslEmptyCacheHelper));
                return helper(IntPtr.Zero, 0);
            }
        }}
      

  6.   

    这个例子我看到过 所以才在C++里动态加载了SslEmptyCacheA 这个函数,但是没有效果
    谁知道我错在哪里
      

  7.   

    typedef BOOL (CALLBACK *pDelSSL)(LPSTR pszTargetName,DWORD dwFlags);
    pDelSSL DelSSL;
    HINSTANCE hdll = NULL;
    hdll = LoadLibrary("Schannel.dll");
    if (hdll != NULL)
    {
    if((DelSSL = (pDelSSL)GetProcAddress(hdll, _T("SslEmptyCacheA"))) == NULL)
    {
    //MessageBox("加载函数失败");
    }
    }
    DelSSL(NULL,0);返回值是1
      

  8.   


    typedef BOOL (CALLBACK *pDelSSL)(LPSTR pszTargetName,DWORD dwFlags);
    pDelSSL DelSSL;
    HINSTANCE hdll = NULL;
    hdll = LoadLibrary("Schannel.dll");
    if (hdll != NULL)
    {
    if((DelSSL = (pDelSSL)GetProcAddress(hdll, _T("SslEmptyCacheA"))) == NULL)
    {
    //MessageBox("加载函数失败");
    }
    }
    BOOL A = DelSSL(NULL,0);
    我这样写有问题吗?
      

  9.   

    typedef BOOL (WINAPI *pDelSSL)(LPSTR pszTargetName,DWORD dwFlags);
      

  10.   


    也是不行。我再详细说明一下吧 网上银行的USBKEY的证书登录使用了IE的SSL 在没有清空SSL前,IE会保留SSL状态,导致其他的USBKEY无法正常使用。
    我的程序里使用了微软的IE控件CWebBrowser2。
    现在即使我使用动态的CWebBrowser2,把控件的指针DELETE掉重新CREATE,也无法清空SSL状态,如果是普通的IE,关掉重新打开后SSL状态则自动清除。
    请问大家有什么高见。
      

  11.   

    Client : Requires Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, or Windows 95. 
    Server :Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0. 以上是该接口SslEmptyCache的应用需求,你的服务器和客户端是否符合要求?
    另外,如果DelSSL(NULL,0)的第一个参数指定的话,是什么结果?
      

  12.   

    谢谢。1.客户端XP SP2 服务器是银行的,所以我也不知道。
    2.如果我想清除网银证书的SSL,第一个参数应该指定为什么?另外,我现在还在疑惑为什么我吧控件的内存都释放了重开,SSL状态还在保留?SSL状态是否保留在程序的进程里的?难道要我把应用程序关闭重开才可以吗?
      

  13.   

    网上银行交易认证的证书登录需要使用SSL。我再详细说明一下吧 网上银行的USBKEY的证书登录使用了IE的SSL 在没有清空SSL前,IE会保留SSL状态,导致其他的USBKEY无法正常使用。 
    我的程序里使用了微软的IE控件CWebBrowser2。 
    现在即使我使用动态的CWebBrowser2,把控件的指针DELETE掉重新CREATE,也无法清空SSL状态,如果是普通的IE,关掉重新打开后SSL状态则自动清除。 
    请问大家有什么高见。
      

  14.   

    正常登录成功后 拔除KEY 执行了动态释放IE控件内存后 不需要插KEY直接选证书登录就成功了。
    正常登录成功后 执行了动态释放IE控件内存后 执行SslEmptyCache 不插KEY不能正常登录 但无法显示网页,之后正常插入KEY后,仍无法登录,好像是SSL的缓存清空了,没有断开SSL连接,始终保持着没有证书的状态。
    另外,登录失败后,即使插KEY, 也不能正常登录。
      

  15.   

    公钥证书是在ie中有备份的,无key不能登陆是因为ie找不到私钥,ssl连接认证失败。
    既然ssl状态已经异常,那么其他的key能用了吗?
      

  16.   

    关键点在与插KEY了也不能正常登录了 这个时候我如果执行一下IE里的清除SSL,就可以正常登录
    其他的KEY同样不能使用
      

  17.   

    已解决
    解决办法详见http://emuio.com/
      

  18.   

    使用了楼主介绍的方法,还是不行!我的系统是XP sp2 rtm版本奇怪的是在其他xp版本上是可以的
      

  19.   

    解决方法:在调用SslEmptyCache 后,调用以下函数,实现清空SSL状态。InternetSetOption(NULL, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0);参考文档:The SslEmptyCache API does not completely do what the IE “Clear SSL State”
    button does. In addition to calling SslEmptyCache — (with parameters (NULL,
    0) I believe, but I have no idea what effect it has) — the “Clear SSL
    State” button tells WinInet (via an undocumented API call) to unload its
    in-memory client certificate cache. There are a couple things you can try to
    get WinInet to discard its in-memory certificate cache (in addition to
    calling SslEmptyCache):
    1. The “brute-force” solution is to close all your WinInet handles,
    dynamically unload WinInet.dll using FreeLibary, and then reload the DLL.
    This requires that you dynamically link to the WinInet API. This solution
    will not work if there are other components within the process that also
    have WinInet loaded (since their references to WinInet will keep the DLL
    loaded in memory).
    2. The “it might work” solution is to close all your WinInet handles and
    call InternetSetOption(NULL, INTERNET_OPTION_END_BROWSER_SESSION, 0, 0).
    This will cause WinInet to discard any cached socket connections and will
    force subsequent HTTPS requests to renegotiate the SSL connection. However,
    WinInet will probably still have a client certificate cached in-memory. If
    you need to use a different client certificate and know which certificate,
    then before calling HttpSendRequest supply the certificate by setting the
    INTERNET_OPTION_CLIENT_CERT_CONTEXT option on the request handle.
    Yet another solution to consider is using the WinHTTP API instead of
    WinInet. WinHTTP is an API similar to WinInet; it supports multi-user
    scenarios much better than WinInet, and this SSL caching problem can also be
    avoided. WinHTTP is available on Windows 2000 SP3/SP4, Windows XP SP1 and
    Windows Server 2003.
      

  20.   

    如果以上不行 需要添加调用完SslEmptyCache后还需要再调用另一个DLL的函数,该函数与SslEmptyCache函数指针类型一样
    h_wininetDLL = LoadLibrary(”wininet.dll”);
    h_Increment = (Function)GetProcAddressh_wininetDLL,”IncrementUrlCacheHeaderData”);
    DWORD buf;
    h_Increment(14,(DWORD)&buf);