Last active
August 29, 2015 14:01
-
-
Save olly/544f07fbd417b6dc4d87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an attempt to the following errors: | |
# | |
# PG::UnableToSend: SSL error: cert already in hash table=0A | |
# | |
# This wraps the OpenID::SimpleSign.store method, from the | |
# ruby-openid-apps-discovery gem, in a thread. I believe the root cause of this | |
# error is that in some environment the store gets duplicate certificates added | |
# to it. This causes OpenSSL errors, which then are raised in the pg gem, | |
# because it believes something serious has gone wrong. | |
# | |
# Wrapping the implementation in a thread, should cause the errors to be scoped | |
# to only that thread. See: https://gist.github.com/olly/9890199 | |
# | |
# We don't care about thread safety here, because we don't actually care which | |
# store _wins_, we just want to suppress the OpenSSL errors. | |
module OpenID::StoreWithThread | |
def store | |
@store ||= begin | |
store = nil | |
Thread.new { store = super }.join | |
store | |
end | |
end | |
end | |
class OpenID::SimpleSign | |
class << self | |
prepend OpenID::StoreWithThread | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment