Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

add support for signing with intermediate certificates #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ios-cert-enrollment/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Configuration
VALID_OPTIONS_KEYS = [
:ssl_certificate_path,
:ssl_key_path,
:intermediate_certificate_paths,
:base_url,
:identifier,
:display_name,
Expand Down
2 changes: 1 addition & 1 deletion lib/ios-cert-enrollment/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def configuration(encrypted_content)


def sign
signed_profile = OpenSSL::PKCS7.sign(SSL.certificate, SSL.key, self.payload, [], OpenSSL::PKCS7::BINARY)
signed_profile = OpenSSL::PKCS7.sign(SSL.certificate, SSL.key, self.payload, SSL.intermediate_certificates, OpenSSL::PKCS7::BINARY)
return Certificate.new(signed_profile.to_der, "application/x-apple-aspen-config")

end
Expand Down
8 changes: 7 additions & 1 deletion lib/ios-cert-enrollment/ssl.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module IOSCertEnrollment
module SSL
@@key, @@certificate = nil
@@key, @@certificate, @@intermediate_certificates = nil
class << self
def key
return @@key if @@key
Expand All @@ -11,6 +11,12 @@ def certificate
return @@certificate if @@certificate
return @@certificate = OpenSSL::X509::Certificate.new(File.read(IOSCertEnrollment.ssl_certificate_path))
end

def intermediate_certificates
return @@intermediate_certificates if @@intermediate_certificates
certificate_paths = IOSCertEnrollment.intermediate_certificate_paths || []
@@intermediate_certificates = certificate_paths.collect{|x| OpenSSL::X509::Certificate.new(File.read(x))}
end
end

end
Expand Down