When you check the option Accept invalid SSL certificates from an importer configuration form, the option is never considered.

In FeedsHTTPFetcher.inc file, you should pass the accept_invalid_cert configuration as an argument when function http_request_get_common_syndication() is called.

  /**
   * Override parent::sourceFormValidate().
   */
  public function sourceFormValidate(&$values) {
    $values['source'] = trim($values['source']);

    // Keep a copy for error messages.
    $original_url = $values['source'];

    $parts = parse_url($values['source']);
    if (empty($parts['scheme']) && $this->config['auto_scheme']) {
      $values['source'] = $this->config['auto_scheme'] . '://' . $values['source'];
    }

    if (!feeds_valid_url($values['source'], TRUE)) {
      $form_key = 'feeds][' . get_class($this) . '][source';
      form_set_error($form_key, t('The URL %source is invalid.', array('%source' => $original_url)));
    }
    elseif ($this->config['auto_detect_feeds']) {
      feeds_include_library('http_request.inc', 'http_request');
      if ($url = http_request_get_common_syndication(
        $values['source'],
        array('accept_invalid_cert' => $this->config['accept_invalid_cert'])
      )) {
        $values['source'] = $url;
      }
    }
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

make77’s picture

Status: Active » Needs review
FileSize
652 bytes

Here is a patch to fix this problem.

make77’s picture

Rename patch...

The last submitted patch, 1: feeds-accpet_invalid_cert_not_used-2419111-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: feeds-accept_invalid_cert_not_used-2419111-2.patch, failed testing.

MegaChriz’s picture

Title: configuration option to allow invalid SSL certificates is not used » Configuration option to allow invalid SSL certificates is not used when option "Auto detect feeds" is enabled
Status: Needs work » Needs review
FileSize
669 bytes

The option "Accept invalid SSL certificates" is not totally ignored, see for example FeedsHTTPFetcherResult::getRaw(), but fails to function when the option "Auto detect feeds" is enabled. An error like the following will occur:

HRCurlException: cURL error (60) SSL certificate problem: unable to get local issuer certificate for https://www.drupal.org/node in http_request_get()

I applied the patch from #2 manually and I can confirm that there is no longer a cURL error when the "Auto detect feeds" option is also enabled. I tested this with using the URL "https://www.drupal.org/node" as input.

Attached is a reformatted patch, created using git. I also moved the function call out of the if statement as I think this improves the readability of the code.

make77’s picture

@MegaChriz, thank you for the explanation ! I created my patch using svn as my project at work uses svn... The documentation doesn't mention svn (https://www.drupal.org/patch/submit) so I suppose we should always use git to create compatible patches ?

MegaChriz’s picture

@make77
There are other options for creating compatible patches (though I do not know them), but for drupal.org, creating patches using git is the recommended way. Important is that the patch is in the "p1" format, which automatically happens when creating a patch with the command "git diff".

MegaChriz’s picture

Issue tags: +Curl, +ssl

  • twistor committed 04ce14e on 7.x-2.x authored by MegaChriz
    Issue #2419111 by make77, MegaChriz: Configuration option to allow...
twistor’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.