mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-04 19:32:02 +00:00
Use prepend to fix OpenSSL::PKey::EC.new on OpenSSL 3.x
alias_method doesn't reliably wrap C-extension class methods. Switch to singleton_class.prepend which correctly intercepts the call chain. Falls back to OpenSSL::PKey.read when EC.new raises on PKCS#8 format keys.
This commit is contained in:
parent
e355809b58
commit
a0ccf676b8
1 changed files with 10 additions and 15 deletions
|
|
@ -1,22 +1,17 @@
|
||||||
require 'openssl'
|
require 'openssl'
|
||||||
|
|
||||||
# Workaround: fastlane 2.234.0 uses OpenSSL::PKey::EC.new which fails on
|
# Fastlane 2.234.0 uses OpenSSL::PKey::EC.new which rejects PKCS#8 keys on
|
||||||
# PKCS#8 keys with OpenSSL 3.x ("invalid curve name"). Fallback to PKey.read.
|
# OpenSSL 3.x ("invalid curve name"). Prepend a wrapper that falls back to
|
||||||
module OpenSSL
|
# OpenSSL::PKey.read, which handles both PKCS#8 and SEC1 formats.
|
||||||
module PKey
|
module OpenSSLECNewFix
|
||||||
class EC
|
def new(arg = nil, *rest)
|
||||||
class << self
|
super
|
||||||
alias_method :_orig_new, :new
|
rescue OpenSSL::PKey::ECError
|
||||||
def new(*args)
|
raise if arg.nil? || !arg.is_a?(String)
|
||||||
_orig_new(*args)
|
OpenSSL::PKey.read(arg)
|
||||||
rescue OpenSSL::PKey::ECError
|
|
||||||
raise unless args.length == 1 && args[0].is_a?(String)
|
|
||||||
OpenSSL::PKey.read(args[0])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
OpenSSL::PKey::EC.singleton_class.prepend(OpenSSLECNewFix)
|
||||||
|
|
||||||
default_platform(:ios)
|
default_platform(:ios)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue