-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional configuration without environment variables #36
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,8 +111,6 @@ def generate_json_pass | |
File.write(@temporary_path.join("pass.json"), pass.to_json) | ||
end | ||
|
||
# rubocop:enable Metrics/AbcSize | ||
|
||
def generate_json_manifest | ||
manifest = {} | ||
Dir.glob(@temporary_path.join("**")).each do |file| | ||
|
@@ -123,14 +121,18 @@ def generate_json_manifest | |
File.write(@manifest_url, manifest.to_json) | ||
end | ||
|
||
CERTIFICATE = Rails.root.join(ENV["PASSKIT_PRIVATE_P12_CERTIFICATE"]) | ||
INTERMEDIATE_CERTIFICATE = Rails.root.join(ENV["PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constants are evaluated at load time, not runtime, so if those envs are nil, this will raise an error at startup of a rails app with |
||
CERTIFICATE_PASSWORD = ENV["PASSKIT_CERTIFICATE_KEY"] | ||
def certificate_path | ||
Rails.root.join(Passkit.configuration.private_p12_certificate) | ||
end | ||
|
||
def intermediate_certificate_path | ||
Rails.root.join(Passkit.configuration.apple_intermediate_certificate) | ||
end | ||
|
||
# :nocov: | ||
def sign_manifest | ||
p12_certificate = OpenSSL::PKCS12.new(File.read(CERTIFICATE), CERTIFICATE_PASSWORD) | ||
intermediate_certificate = OpenSSL::X509::Certificate.new(File.read(INTERMEDIATE_CERTIFICATE)) | ||
p12_certificate = OpenSSL::PKCS12.new(File.read(certificate_path), Passkit.configuration.certificate_key) | ||
intermediate_certificate = OpenSSL::X509::Certificate.new(File.read(intermediate_certificate_path)) | ||
|
||
flag = OpenSSL::PKCS7::DETACHED | OpenSSL::PKCS7::BINARY | ||
signed = OpenSSL::PKCS7.sign(p12_certificate.certificate, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thrown that in here since we use it in our app to conditionally display passkit-related view code only if the gem is properly configured.