How to secure classic ASP ASPSESSIONID cookie?

后端 未结 4 1882
太阳男子
太阳男子 2021-01-04 22:31

Is there a way to mark classic ASP ASPSESSIONID* cookies as secure? It appears that the ASP ISAPI handler adds that session id cookie after my page is done rendering so put

4条回答
  •  执念已碎
    2021-01-04 23:15

    As found here, an UrlRewrite rule can handle this.

    The rules below handle it for adding both HttpOnly and Secure if they are missing on the ASPSESSIONID cookie. (For other cookies, normally they are emitted by the site ASP code: better handle that directly in the code responsible for them.)

    
      
        
          
            
            
          
          
            
            
            
              
            
          
          
            
              
            
            
              
            
          
        
      
    
    

    If UrlRewrite is not installed in the IIS Server, this will crash the site.

    Note that the Secure rule should not be applied if the site is legitimately accessed over http instead of https, thus the condition for not emitting it when browsing it locally. If Secure is emitted for a site accessed over http from the client end, the client will not send the cookie back to the server.

    (I avoid testing the inbound protocol, because the sites I work on are not supposed to be accessed on http anyway, excepted eventually directly from their hosting server or load-balancer.)

    I have previously tried using asp/session/keepSessionIdSecure, but it has no effect (at least for a site behind a load-balancer terminating the https and accessing the site server over http). This setting is the modern version (IIS 7+) of the AspKeepSessionIDSecure Metabase value pointed by AnthonyWJones answer.

提交回复
热议问题