开发者

Error in HTTPS for a self signed certificate

This is in VS 2005. And IIS is 6.0. I am trying to use Self signed certificate for HTTPS. In the code i am redirecting from http to https for few pages. It is nt working fine. And in the IIS manager, for each page that i want HTTPs, i have changed its setting by checking "Require Secure Channel(SSL)" and "Require 128 bit encryption".

public void setSecureProtocol()
    {
        string redirectUrl = null;
        bool bSecure = true;
        bool SecureConnection = true;
        if (bSecure && SecureConnection)
            redirectUrl = Request.Url.ToString().Replace("http:", "https:");
        else
            if (!bSecure && SecureConnection)
                redirectUrl = Request.Url.ToString().Replace("https:", "http:");

        if (redirectUrl != null)
            Response.Redirect(redirectUrl);
   }

Pages throw me an error like this

The page must be viewed over 开发者_运维知识库a secure channel The page you are trying to access is secured with Secure Sockets Layer (SSL).

Please try the following:

* Type https:// at the beginning of the address you are attempting to reach and press ENTER.

HTTP Error 403.4 - Forbidden: SSL is required to view this resource. Internet Information Services (IIS)Internet Information Services (IIS)

When i try to put https in the start of the URl, it wont call. I have no idea whats wrong in here. Please help me out.

Here,

Its not redirecting from http to https.

For the pages that i am not redirecting in the code behind, and changing in the IIS, i can see the HTTPS when i check the two checkboxes.

Please someone help me!!!! Thanks a lot in advance!

Internet Information Services (IIS)


@Ram I think that I found the problem.

i have changed its setting by checking "Require Secure Channel(SSL)" and "Require 128 bit encryption"

You have restrict the http for this pages, so when you call it as http, the page is not loaded at all to make your code run and redirect it to https.

So remove the restricts for http for that pages to let it run and allow the switch, and you just take care to always be https.

This is a very nice code to do that

Other way is to change all the links to the page that you wish to be secure, and send it with https, and not wait to get on that pages to change them from code behind.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜