Changesets can be listed by changeset number.
The Git repository is here.
Changeset 437
Support SSL fetches for news extension XML feeds, with certificate chains.
- Comitted by: rool
- Date: Friday August 30 03:21:52 2013 (over 11 years ago)
Affected files:
- rool/rails/radiant/trunk/vendor/extensions/news_tag/lib/news_tag.rb (diff)
- rool/rails/radiant/trunk/vendor/extensions/news_tag/news_tag_extension.rb (diff)
rool/rails/radiant/trunk/vendor/extensions/news_tag/lib/news_tag.rb:
prev. | current | |
# See "news_tag_extension.rb" for details. | ||
3 | require 'uri' | |
4 | require 'net/https' | |
5 | ||
module NewsTag | ||
include Radiant::Taggable | ||
... | ... | |
Note that '<' and '>' characters in RSS item titles will always be | ||
escaped to HTML entities for security. | ||
48 | ||
49 | If you want to use HTTPS fetches for feeds and your HTTPS server | |
50 | requires a certificate chain, you'll need to ensure that Radiant | |
51 | runs with environment variable SSL_CERT_CHAIN pointing to the | |
52 | full file path of the relevant ".crt" bundle. Otherwise you will | |
53 | see SSL errors thrown by Ruby instead of your parsed XML data. | |
} | ||
tag "news" do |tag| | ||
... | ... | |
# Fetch the feed and parse it. | ||
59 | | |
68 | uri = URI.parse(feed) | |
69 | rss = if (uri.scheme == 'https') | |
70 | ||
71 | cert_chain = ENV['SSL_CERT_CHAIN'] | |
72 | https = Net::HTTP.new(uri.host, uri.port) | |
73 | https.use_ssl = true | |
74 | https.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
75 | https.ca_file = cert_chain unless (cert_chain.nil? || cert_chain.empty?) | |
76 | ||
77 | feed_data = https.start do |http| | |
78 | request = Net::HTTP::Get.new(uri.request_uri) | |
79 | response = https.request(request) | |
80 | ||
81 | raise "#{ response.code }: #{ response.messages }" unless (response.code.to_i >= 200 && response.code.to_i <= 299) | |
82 | response.body | |
83 | end | |
84 | ||
85 | RSS::Parser.parse(feed_data) | |
86 | ||
87 | else | |
88 | RSS::Parser.parse(feed) | |
89 | ||
90 | end | |
91 | ||
done = 0 | ||
out = "<ul>\n" | ||
rool/rails/radiant/trunk/vendor/extensions/news_tag/news_tag_extension.rb:
prev. | current | |
# in URIs, as well as feeds that have not. | ||
# 2011-03-06 (ADH): Imported into Radiant 0.9.1 as an Extension. | ||
# 2011-03-16 (ADH): Added Atom feed compatibility. | ||
34 | # 2013-08-30 (ADH): Added SSL certificate chain fetch support. | |
# Uncomment this if you reference any of your controllers in activate | ||
# require_dependency 'application_controller' |