From e05ee7558f80e6968f2e093d1001cfb6a5e9ef4e Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Thu, 27 Jul 2023 10:20:11 -0500 Subject: [PATCH 1/2] Raise a more helpful message --- app/models/apple/api.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/apple/api.rb b/app/models/apple/api.rb index 622ab571b..3dd5c5def 100644 --- a/app/models/apple/api.rb +++ b/app/models/apple/api.rb @@ -10,10 +10,16 @@ class Api attr_accessor :provider_id, :key_id, :key, :bridge_url def self.from_env - apple_key_pem = Base64.decode64(ENV["APPLE_KEY_PEM_B64"]) + apple_key_id = ENV["APPLE_KEY_ID"] + apple_provider_id = ENV["APPLE_PROVIDER_ID"] + apple_key_pem_b64 = ENV["APPLE_KEY_PEM_B64"] - new(provider_id: ENV["APPLE_PROVIDER_ID"], - key_id: ENV["APPLE_KEY_ID"], + raise "Apple::Api.from_env Apple key details missing from ENV" if [apple_key_id, apple_provider_id, apple_key_pem_b64].any?(&:blank?) + + apple_key_pem = Base64.decode64(apple_key_pem_b64) + + new(provider_id: apple_provider_id, + key_id: apple_key_id, key: apple_key_pem) end From aafcfdb39d261c51c965da287d0e3fc0ee6fedba Mon Sep 17 00:00:00 2001 From: Sam Vevang Date: Thu, 27 Jul 2023 11:09:17 -0500 Subject: [PATCH 2/2] Use custom inspect for api --- app/models/apple/api.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/apple/api.rb b/app/models/apple/api.rb index 3dd5c5def..f07c941f9 100644 --- a/app/models/apple/api.rb +++ b/app/models/apple/api.rb @@ -46,6 +46,10 @@ def initialize(provider_id:, key_id:, key:, bridge_url: nil) @bridge_url = URI(bridge_url) end + def inspect + "#" + end + def ec_key @ec_key ||= OpenSSL::PKey::EC.new(key) end