SOS! enabling 'UseSSL' in web.config ends up with HTTPS pages in endless loop!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi, got an SSL certificate installed by host today but after setting  <add key="UseSSL" value="True" /> in web.config I can't access any pages or links to pages using https:// - I found the following solutions:

https://www.nopcommerce.com/boards/t/1093/redirect-loop.aspx?p=2
http://www.webdesigncompany.co.uk/blog/2011/9/8/running-nopcommerce-with-ssl-through-ec2-elb/

But not being a dev (& not being very bright) I can't for the life of me figure out where the 'CommonHelper' class/CommonHelper.cs is so I can try the solutions.

Can anyone tell me where to find the 'CommonHelper' class?
& once I 've changed it do I need to do anything like recompile the whole site?

Thanks for reading.

[ps using v1.9]
12 years ago
\Libraries\Nop.Common\Utils\CommonHelper.cs file (You need source code package)
12 years ago
Thankyou Andrei
12 years ago
OK  I've changed EnsureSSL function as per codewarrior's solution here: https://www.nopcommerce.com/boards/t/1093/redirect-loop.aspx?p=2 and changed the server variable to read ["HTTP_X_FORWARDED_PROTO"] as it should for my server host.

Now When I rebuild nop.Common I get the following error:

Error  1  The name 'SettingManager' does not exist in the current context  I:\1_inklabs™\_ct11_pre01\SITE_FILES_PRE\nopCommerce_1.90_Source\Libraries\Nop.Common\Utils\CommonHelper.cs  690  21  Nop.Common

Can anyone tell me what i'm doing wrong and how I can fix it?

Thanks
12 years ago
Have you added required namespace for SettingManager?
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings
12 years ago
I hadn't no, but now I have added it to CommonHelper.cs I get:

Error  1  The type or namespace name 'BusinessLogic' does not exist in the namespace 'NopSolutions.NopCommerce' (are you missing an assembly reference?)

Thanks
12 years ago
Just looked at the forum post you referenced. It's about some old nopCommerce version. If you're using 1.90, try the next steps:
1. Open CommonHelper.cs file
2. Find the following line of code and uncomment it
\\useSSL = HttpContext.Current.Request.ServerVariables["HTTP_CLUSTER_HTTPS"] == "on" ? true : false;

3. Recompile the solution
12 years ago
Ok, that's easier :)  - it compiled fine with no errors. However it doesn't appear to have solved HTTPS redirect/loop problem. As soon as add key="UseSSL" value is set to true and application pool recycled on server accessing https pages/links still returns the same old errors in the browser.

The Errors I'm still getting:

[Safari]
This web page has a redirect loop
The web page at https://mydomain/login.aspx has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

[FF]
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

TO RECAP WHAT I'VE DONE:

1) IN CommonHelper.cs I have set the following@ Line 334
(server variable details from my host - http://forums.tsohost.co.uk/clustered-hosting-platform-windows-hosting/747-ssl-detection.html)

public static bool IsCurrentConnectionSecured()
        {
            bool useSSL = false;
            if (HttpContext.Current != null && HttpContext.Current.Request != null)
            {
                //useSSL = HttpContext.Current.Request.IsSecureConnection;
                //when your hosting uses a load balancer on their server then the Request.IsSecureConnection is never got set to true, use the statement below
                //just uncomment it
                useSSL = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_PROTO"] == "on" ? true : false;
            }

            return useSSL;
        }

2) I have compiled the solution, checked date/time of Nop.Common.DLL & uploaded to server.
3) I set <add key="UseSSL" value="True" /> in web.config
4) I recycle application pool on server

RESULT:
Same errors as I had before...
12 years ago
OK, it would appear uncommenting the line:
useSSL = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_PROTO"] == "on" ? true : false;
is for sharedSSL!

I need to look for the header ["HTTP_X_FORWARDED_PROTO"] so have tried:

useSSL = HttpContext.Current.Request.Headers["HTTP_X_FORWARDED_PROTO"] == "on" ? true : false;
(this just returns redirect loop error)

also tried

useSSL = HttpContext.Current.Request.Headers["HTTP_X_FORWARDED_PROTO"].ToLower() == "https";

this just returns 'Object reference not set to an instance of an object.' error

Can anyone tell me what this line should read? I don't really know what I'm doing :)  thanks
11 years ago
Did you resolve this issue?  I am experiencing the same issue.  If so, please let me know what you did to resolve the issue...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.