CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Force Secure URLs throwing error when saved
Pages: [1] 2

Author Topic: Force Secure URLs throwing error when saved  (Read 10589 times)

jrosen

  • Guest
Force Secure URLs throwing error when saved
July 10, 2009, 08:10:46 pm
I am using CiviCRM 2.2.3 and have a valid SSL certificate setup for https://www.pinkelephantgames.com.

When I navigate to Settings - Resource URLS https://www.pinkelephantgames.com/civicrm/admin/setting/url) and select Force Secure URLS and then click "Save", I get the following error message:

Code: [Select]
Please correct the following errors in the form fields below:
You need to set up a secure server before you can use the Force Secure URLs option

I took a look at my Apache access_log and saw this:
Code: [Select]
(MY CLIENT IP) - - [10/Jul/2009:19:49:44 -0700] "POST /civicrm/admin/setting/url HTTP/1.1" 200 26225 "https://www.<domain>.com/civicrm/admin/setting/url" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; GTB6; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; MS-RTC LM 8)"

(WEBSERVER IP) - - [10/Jul/2009:19:50:22 -0700] "GET /civicrm/dashboard?reset=1 HTTP/1.1" 403 5780 "-" "PEAR HTTP_Request class ( http://pear.php.net/ )"

It looks like CiviCRM is trying to access the CiviCRM dashboard page to see if SSL is enabled and is getting a forbidden (403) response.  It is 403 because CiviCRM is not logged into the website when it is trying to access the dashboard (Drupal permissions are set so that only Administrators can access the CiviCRM Dashboard).  Why isn't it trying to access the default page (https://www.pinkelephantgames.com)?

Please help, I am trying to get SSL working for the site.

Thanks,
Jason

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Force Secure URLs throwing error when saved
July 11, 2009, 12:19:10 am
I don't think you are correct about the credentials. I believe civicrm will be using your credentials or similarly empowered credentials to access that page.

CiviCRM tests that the https path to the CiviCRM pages is valid (it could be invalid even if your main url is invalid.)

Something doesn't quite make sense though -did you change the apache snippet below to be <domain> instead of your domain - It would seem odd since you have posted your url elsewhere. Unless your url is set wrong somewhere

"https://www.<domain>.com/civicrm/admin/setting/url"

Are your resource Urls correct?

The other area that often causes problems is the apache redirect settings - for example if https://yourdomain.com works and https://www.yourdomain.com doesn't you might have a problem. Make sure that you can access the CiviCRM pages with an https prefix with and without the www.

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

jrosen

  • Guest
Re: Force Secure URLs throwing error when saved
July 11, 2009, 12:29:30 am
Yes, I did change the snippet to be <domain> - not sure why I did that.  Was pretty tired when I wrote the post earlier.

I can access the site both with and without 'www' prefix.  My resource URLs are correct too - they use http:// protocol prefix, though.

Not sure what the issue is myself.  For now, I have given up on using CiviCRM's built in HTTPS redirection and have setup some Apache .htaccess mod_rewrite rules to cover myself (tight delivery deadline on the site I am working on).

But if you or anyone else has any ideas, please let me know.  Would be nice to let CiviCRM manage its own HTTPS.

Thanks

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Force Secure URLs throwing error when saved
July 20, 2009, 12:18:10 am
Check out the issue tracker (link at top of this page) and search for issue CRM-4447.

CRM/Utils/System.php::redirectToSSL() works by checking a test URL with the HTTPS scheme before redirecting to the target URL.

In the past this test URL has been the home address on the site, and then it was the Dashboard, and subsequent to this fix it has been changed so be the target URL.

You might want to try applying the patches, or upgrading to 2.2.4. Perhaps this will help?

Ken

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: Force Secure URLs throwing error when saved
July 20, 2009, 12:28:24 am
jrosen :

You might want to apply the following patches:
http://fisheye.civicrm.org/changelog/CiviCRM?cs=21044
http://fisheye.civicrm.org/changelog/CiviCRM?cs=21386

hth
-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

jrosen

  • Guest
Re: Force Secure URLs throwing error when saved
November 02, 2009, 03:50:24 pm
I am now working on a different site using CiviCRM 3.02 and I am having the same issue where I cannot get CiviCRM to enable secure URLs because it is getting a 403 error when it tries to access the https:<myserver>/civicrm/dashboard?reset=1 URL.  When I am logged in as an administrator that has privileges to the CiviCRM dashboard, I do not receive a 403 (I receive a 200) when I access the same URL in my browser.

So, I did some digging around the CiviCRM code and found the codepath where this all gets checked and set:  CRM/Admin/Form/Setting/Url.php:formRule
In there, it has CiviCRM try to access https:<myserver>/civicrm/dashboard?reset=1.  In my Drupal installation, I have permissions set such that only the "admin" role has access to the dashboard.  CiviCRM is getting 403 returned, which makes CRM/Admin/Form/Setting/Url.php:formRule fail and throw an error.

In my installation, I temporarily modified CRM/Admin/Form/Setting/Url.php:formRule to check https://<myserver>/ and it had no issues and I could set CiviCRM to use SSL.  Since the CiviCRM documentation states that you should not enable the Dashboard for anonymous users (o not enable this for the "anonymous" role) - it seems odd that it would use check the Dashboard as an anonymous user to see if SSL is possible.

I think the code should be modified to check another URL so that SSL can be enabled once proper security is set.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Force Secure URLs throwing error when saved
November 02, 2009, 04:30:01 pm

hmm, isnt the admin page also restricted to the "admin" role? I dont think we expected that someone with settings to change the site url etc will not have access to the dashboard

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jrosen

  • Guest
Re: Force Secure URLs throwing error when saved
November 02, 2009, 04:34:01 pm
The "admin" user I was logged in with to set the SSL setting has full Drupal access to all modules (including all CiviCRM modules).  The "admin" user I was using has access to the dashboard and all CiviCRM permissions.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Force Secure URLs throwing error when saved
November 02, 2009, 06:07:47 pm

if u check the file/function: CRM/Utils/System.php, function checkURL

we are also sending in all the cookies back to the server. i.e. we are impersonating your current login status (which is admin). thus the page should be returning a 200 response code

any idea why it is not?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jrosen

  • Guest
Re: Force Secure URLs throwing error when saved
November 03, 2009, 07:18:50 am
I did notice the checkURL function and the addCookie section:
Code: [Select]
       
if ( $addCookie ) {
            foreach ( $_COOKIE as $name => $value ) {
                $request->addCookie( $name, $value );
            }
        }

I have not yet taken a look to see why that code is not adding in my authentication cookies...

I will take a look and let you know.

Jason

mnestor

  • I’m new here
  • *
  • Posts: 9
  • Karma: 2
Re: Force Secure URLs throwing error when saved
April 03, 2010, 03:45:09 pm
Has a solution been found yet? I'm on 3.13 and got SSL working but I'm getting this error when trying to do this.

mnestor

  • I’m new here
  • *
  • Posts: 9
  • Karma: 2
Re: Force Secure URLs throwing error when saved
April 03, 2010, 04:15:02 pm
Figured out my problem. I also use the drupal module securepages and you have to ignore civicrm* in order for civicrm to be able to work with ssl correctly.

Edit: Sorry, forgot to say that you need to ignore IF you enable "Switch back to http pages when there are no matches" and also make sure you don't put civicrm into the list of secure pages.
« Last Edit: April 03, 2010, 04:19:31 pm by mnestor »

greenmachine

  • I post occasionally
  • **
  • Posts: 58
  • Karma: 6
Re: Force Secure URLs throwing error when saved
July 04, 2010, 10:24:29 am
I am experiencing the same problem of a spurious "you must enable SSL first..." error on 3.1.3, on a site where https is working fine (I can visit the dashboard URL on https no problem). It's a volunteer site, so I don't really have time to debug this. I ended up just commenting out the "return $errors;" line in formRule() of CRM/Admin/Form/Setting/Url.php. Sorry that I couldn't be more helpful.

dafeder

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
  • MySQL version: 5.092
  • PHP version: 5.2
Re: Force Secure URLs throwing error when saved
May 10, 2011, 11:51:54 am
Same problem on 3.3! Frustrating...

dafeder

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
  • MySQL version: 5.092
  • PHP version: 5.2
Re: Force Secure URLs throwing error when saved
May 10, 2011, 01:25:38 pm
I guess there are a lot of different issues that can cause this, I figured out what mine was. In my civicrm.settings.php, I had my CIVICRM_UF_BASEURL constant defined without the "www" subdomain thing, but had set up my resource urls to use www. The redirect from mydomain.com to www.domain.com was messing up Civi's function to check the secure urls.

So, to make sure I have no funny www business, I put my CIVICRM_UF_BASEURL with the www. prefix, and in my .htaccess file I have

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^mydomain\.org$ [NC]
RewriteRule ^(.*)$ https://www.mydomain.org/$1 [L,R=301]
 
RewriteCond %{HTTP_HOST} ^mydomain\.org$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.org/$1 [L,R=301]

So far, working fine.

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Force Secure URLs throwing error when saved

This forum was archived on 2017-11-26.