Skip to content

Commit 3fc3451

Browse files
Remove bundled root certificates
1 parent d7315e3 commit 3fc3451

7 files changed

Lines changed: 11 additions & 3555 deletions

File tree

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ See [versioning in the API reference][versioning] for more information.
151151

152152
### Configuring CA Bundles
153153

154-
By default, the library will use its own internal bundle of known CA
154+
By default, the library will use the system bundle of known CA
155155
certificates, but it's possible to configure your own:
156156

157157
```ruby
@@ -268,7 +268,7 @@ end
268268
### How to use undocumented parameters and properties
269269

270270
In some cases, you might encounter parameters on an API request or fields on an API response that aren’t available in the SDKs.
271-
This might happen when they’re undocumented or when they’re in preview and you aren’t using a preview SDK.
271+
This might happen when they’re undocumented or when they’re in preview and you aren’t using a preview SDK.
272272
See [undocumented params and properties](https://docs.stripe.com/sdks/server-side?lang=ruby#undocumented-params-and-fields) to send those parameters or access those fields.
273273

274274
### Writing a Plugin
@@ -413,13 +413,6 @@ just lint
413413
# or: bundle exec rubocop
414414
```
415415

416-
Update bundled CA certificates from the [Mozilla cURL release][curl]:
417-
418-
```sh
419-
just update-certs
420-
# or: bundle exec rake update_certs
421-
```
422-
423416
[api-keys]: https://dashboard.stripe.com/account/apikeys
424417
[connect]: https://stripe.com/connect
425418
[curl]: http://curl.haxx.se/docs/caextract.html

Rakefile

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,3 @@ task default: %i[test rubocop]
77
Rake::TestTask.new do |t|
88
t.pattern = "./test/**/*_test.rb"
99
end
10-
11-
desc "Update bundled certs"
12-
task :update_certs do
13-
require "net/http"
14-
require "uri"
15-
16-
fetch_file "https://curl.se/ca/cacert.pem",
17-
File.expand_path("lib/data/ca-certificates.crt", __dir__)
18-
end
19-
20-
#
21-
# helpers
22-
#
23-
24-
def fetch_file(uri, dest)
25-
File.open(dest, "w") do |file|
26-
resp = Net::HTTP.get_response(URI.parse(uri))
27-
unless resp.code.to_i == 200
28-
abort("bad response when fetching: #{uri}\n" \
29-
"Status #{resp.code}: #{resp.body}")
30-
end
31-
file.write(resp.body)
32-
puts "Successfully fetched: #{uri}"
33-
end
34-
end

justfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ lint: (format-check "--autocorrect")
2525
# copy of `lint` with less output
2626
format: (format-check "-o /dev/null --autocorrect")
2727

28-
update-certs: install
29-
bundle exec rake update_certs
30-
3128
# run sorbet to check type definitions
3229
typecheck: install
3330
{{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \

lib/data/ca-certificates.crt

Lines changed: 0 additions & 3511 deletions
This file was deleted.

lib/stripe.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
require "stripe/services/oauth_service"
6767

6868
module Stripe
69-
DEFAULT_CA_BUNDLE_PATH = __dir__ + "/data/ca-certificates.crt"
70-
7169
# map to the same values as the standard library's logger
7270
LEVEL_DEBUG = Logger::DEBUG
7371
LEVEL_ERROR = Logger::ERROR

lib/stripe/stripe_configuration.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Stripe
55
#
66
# =ca_bundle_path=
77
# The location of a file containing a bundle of CA certificates. By default
8-
# the library will use an included bundle that can successfully validate
8+
# the library will use the system bundle that can successfully validate
99
# Stripe certificates.
1010
#
1111
# =log_level=
@@ -66,7 +66,7 @@ def reverse_duplicate_merge(hash)
6666

6767
def initialize
6868
@api_version = ApiVersion::CURRENT
69-
@ca_bundle_path = Stripe::DEFAULT_CA_BUNDLE_PATH
69+
@ca_bundle_path = nil
7070
@enable_telemetry = true
7171
@verify_ssl_certs = true
7272

@@ -190,7 +190,11 @@ def ca_bundle_path=(path)
190190
def ca_store
191191
@ca_store ||= begin
192192
store = OpenSSL::X509::Store.new
193-
store.add_file(ca_bundle_path)
193+
if ca_bundle_path.nil?
194+
store.set_default_paths
195+
else
196+
store.add_file(ca_bundle_path)
197+
end
194198
store
195199
end
196200
end

test/stripe/stripe_configuration_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class StripeConfigurationTest < Test::Unit::TestCase
88
should "initialize a new configuration with defaults" do
99
config = Stripe::StripeConfiguration.setup
1010

11-
assert_equal Stripe::DEFAULT_CA_BUNDLE_PATH, config.ca_bundle_path
11+
assert_nil config.ca_bundle_path
1212
assert_equal true, config.enable_telemetry
1313
assert_equal true, config.verify_ssl_certs
1414
assert_equal 5, config.max_network_retry_delay
@@ -137,7 +137,7 @@ class StripeConfigurationTest < Test::Unit::TestCase
137137
assert_equal("client_uploads_base.stripe.com", client_config.base_addresses[:files]) # client uploads base
138138
assert_equal(Stripe::DEFAULT_API_BASE, client_config.base_addresses[:api]) # default api base
139139
assert_equal(ApiVersion::CURRENT, client_config.api_version) # default api version
140-
assert_equal(Stripe::DEFAULT_CA_BUNDLE_PATH, client_config.ca_bundle_path) # default ca bundle path
140+
assert_nil client_config.ca_bundle_path # default ca bundle path
141141
end
142142
end
143143

0 commit comments

Comments
 (0)