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 »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • "Force Secure URLs" and shared certificates?
Pages: [1]

Author Topic: "Force Secure URLs" and shared certificates?  (Read 5469 times)

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
"Force Secure URLs" and shared certificates?
September 07, 2008, 03:19:42 am
G'day,

I am in a shared hosting environment and was wondering if "Force Secure URLs (SSL)" can be made to work with a shared certificate.
So that if my site is http://mysite.com critical operations could be redirected to an address I specify, like https://mysite.myprovider.com, and then return when finished (or stay there if that makes things simpler).

As I'm seeing no way to specify a target for https, I assume that by default the forced secure URLs would just be replacing http with https but keep using the same server and path (i.e. replace http://mysite.com with https://mysite.com). I have looked at using a redirect or rewrite directive in .htaccess, but get a "missing certificate" message as soon as I hit the site with https, so that would not do the trick.

Is there a way to do what I am after?

TIA,

Ronald

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" and shared certificates?
September 07, 2008, 08:37:18 am
Quote from: ronald on September 07, 2008, 03:19:42 am
Is there a way to do what I am after?

I'm not aware of other ways to do this. this has come up  a bit in the past, so would be great for the community to contribute a patch (or sponsor) this functionality. This might dovetail nicely with the functionality to support relative urls

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

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
September 07, 2008, 10:11:35 am
Thanks Lobo.
I guess those with the funds to potentially sponsor the functionality don't have the problem because they get their own certificate in the first place.

Cheers,

Ronald

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" and shared certificates?
September 07, 2008, 04:45:34 pm

the issue is a bit non-trivial to fix (else it would have been fixed already)

if we find its relatively easy to do when we do the relative url fix, we'll integrate it for 2.2, else it will be up to the community to contribute a patch

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

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
September 07, 2008, 05:50:05 pm
Sounds good, thanks.  :)

Ronald

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
November 12, 2008, 05:37:31 am
Meanwhile...

I think I have found the spot where the substitution is done and am very tempted to do very bad things in order to avoid the cost for a certificate and dedicated IP...

civicrm-2.1.1/CRM/Utils/System.php has this in line 383f:
Code: [Select]
$config->userFrameworkResourceURL = str_replace( 'http://', 'https://',
                                             $config->userFrameworkResourceURL );

I know that this is ugly, but would changing that to
Code: [Select]
$config->userFrameworkResourceURL = str_replace( 'http://mydomain.com', 'https://mydomain.myhost.com',
                                             $config->userFrameworkResourceURL );

do what I want, or are there any side-effects to be expected (other than trouble with the next upgrade)?

Can you think of any way to make this less bad, e.g. modify that value from somewhere else without hacking core files and hard-wiring values into them? (Consider that I know this should be done using a database or at least an extra file with those values but have no clue how to do that.)

TIA,

Ronald

[edit: fixed inaccurate term]
« Last Edit: November 12, 2008, 02:14:45 pm by ronald »

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" and shared certificates?
November 12, 2008, 07:37:21 am

I think the below is fine and an acceptable hack (IMO). You might also want to check: CRM/Utils/System/Drupal.php, function mapConfigToSSL( ) (thought i think this function is not needed in drupal 6)

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

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
November 12, 2008, 02:15:40 pm
Lobo,

Thanks for your feedback and the pointer, much appreciated.  :)

Ronald

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
November 22, 2008, 03:37:58 am
Ok, so I did enable "Force secure URL" and got a blank page with an "https" URL.
Trying to go back- or forward, or directly access known pages (substituting "https" with "http"), resulted in blank pages with "https" URLs as well.

Not so good. I tried to find the setting in the database and my guess is it's somewhere in civicrm_domain.config_backend, however the contents of that field proved completely incomprehensible to me. (Seems like there's a whole bunch of settings squeezed into that single field in some pattern I could not quite work out. Surely worth a comment as well but I'll skip that for now... :-X)

So I looked around the code some more and found more places where string replacements take place:
/CRM/Admin/Form/Setting/Url.php
/CRM/Core/Config.php

Patched those as well and then I got at least a certificate warning, telling me that the certificate for https://mydomain.com belongs to https://*.myprovider.com.
[Edit] (Seems my provider has installed that certificate for my domain to allow for https connections, even if they induce certificate errors.) [/Edit]

So I "allow an exception" and finally come back into the CiviCRM admin section, with a red warning at the top stating
Quote
warning: file_put_contents(Config.IDS.ini): failed to open stream: Permission denied in /path/to/civicrm/CRM/Core/IDS.php on line 108.

However the URL shown in the location bar still is https://mydomain.com even though that can't really be. (Again, because that domain does not have a certificate installed at all.) So it seems a bit as if the URL the browser shows was different from the one that's actually accessed. Can that be? If so, why would that have happened? If not, what else could be going on?

Also, it seems that since I got a white page rather than an error message on my first attempt, this code
...
in civicrm/CRM/Admin/Form/Setting/Url.php does not really seem to do what one would expect. Or am I missing something?


I guess for now I'll revert that setting again, but I'd really like to know what's going on there and how to get it to work.
[Edit] Reverting that setting was tricky, too, because the links on the site happily pointed to and fro between https://mydomain.com and https://mydomain.myprovider.com, so I had to login to both. Also note that both are https URLs - I would have understood if it were http://mydomain.com and https://mydomain.myprovider.com, in fact that would have been close to my original intentions, but though the host was exchanged, the protocol stayed at https.[/Edit]

TIA for any hints,

Ronald
« Last Edit: November 22, 2008, 04:17:11 am by ronald »

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" and shared certificates?
November 23, 2008, 06:59:05 am
Quote from: ronald on November 22, 2008, 03:37:58 am
Not so good. I tried to find the setting in the database and my guess is it's somewhere in civicrm_domain.config_backend, however the contents of that field proved completely incomprehensible to me. (Seems like there's a whole bunch of settings squeezed into that single field in some pattern I could not quite work out. Surely worth a comment as well but I'll skip that for now... :-X)

We use PHP's serialize function which is pretty well documented in the PHP manual (http://www.php.net/serialize)

I'm not sure why you got the IDS error.  You might want to check the apache logs and see what url is being accessed etc. Also check what settings file civicrm reads when you access via https (this might be the cause for your IDS error)

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

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
November 26, 2008, 04:14:09 pm
Thanks for the information, Lobo, much appreciated.
There's only one settings file but maybe that's part of the problem - have to do some more playing around with this.

Ronald

ronald

  • I post occasionally
  • **
  • Posts: 48
  • Karma: 5
Re: "Force Secure URLs" and shared certificates?
December 16, 2008, 01:15:43 am
I have played around with it a bit more but didn't really get anywhere. I've also played with other stuff and now completely shot my testing site.
Giving up on this one for now - probably not quite as trivial as I had hoped.

Thanks for all your help!  :)

Ronald

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • "Force Secure URLs" and shared certificates?

This forum was archived on 2017-11-26.