From a0ccf676b840f0ec5660955b500423bbf575303a Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Mon, 18 May 2026 19:27:26 -0400 Subject: [PATCH] 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. --- mobile/fastlane/Fastfile | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mobile/fastlane/Fastfile b/mobile/fastlane/Fastfile index 0bd6c98..57f5ff3 100644 --- a/mobile/fastlane/Fastfile +++ b/mobile/fastlane/Fastfile @@ -1,22 +1,17 @@ require 'openssl' -# Workaround: fastlane 2.234.0 uses OpenSSL::PKey::EC.new which fails on -# PKCS#8 keys with OpenSSL 3.x ("invalid curve name"). Fallback to PKey.read. -module OpenSSL - module PKey - class EC - class << self - alias_method :_orig_new, :new - def new(*args) - _orig_new(*args) - rescue OpenSSL::PKey::ECError - raise unless args.length == 1 && args[0].is_a?(String) - OpenSSL::PKey.read(args[0]) - end - end - end +# Fastlane 2.234.0 uses OpenSSL::PKey::EC.new which rejects PKCS#8 keys on +# OpenSSL 3.x ("invalid curve name"). Prepend a wrapper that falls back to +# OpenSSL::PKey.read, which handles both PKCS#8 and SEC1 formats. +module OpenSSLECNewFix + def new(arg = nil, *rest) + super + rescue OpenSSL::PKey::ECError + raise if arg.nil? || !arg.is_a?(String) + OpenSSL::PKey.read(arg) end end +OpenSSL::PKey::EC.singleton_class.prepend(OpenSSLECNewFix) default_platform(:ios)