使用Ruby on Rails签署iPhone配置XML配置文件 [英] Signing iPhone Configuration XML Profile with Ruby on Rails
问题描述
我正在生成一个有效的iPhone配置XML配置文件并通过Rails页面提供它。
I am generating a valid iPhone Configuration XML Profile and delivering it via a Rails page.
我试图弄清楚如何以编程方式对XML文件进行签名x509证书,以便iPhone将其识别为已签名的个人资料
I am trying to figure out how to programmatically sign the XML file with an x509 certificate so that the iPhone recognizes it as a signed profile
这是一个关于签署iPhone配置文件所涉及内容的好教程
http://www.rootmanager.com/iphone-ota-配置/ iphone-ota-setup-with-signed-mobileconfig.html
This is a good tutorial about what's involved in signing an iPhone Config Profile http://www.rootmanager.com/iphone-ota-configuration/iphone-ota-setup-with-signed-mobileconfig.html
具体来说,在命令行执行此操作会签署无符号文件 company.mobileconfig
Specifically, doing this on the command line would sign the unsigned file company.mobileconfig
openssl smime -sign -in company.mobileconfig -out signed.mobileconfig -signer server.crt -inkey server.key -certfile cert-chain.crt -outform der -nodetach
Ruby中的等效命令是什么在Rails上,假设我有X. ML文件在一个字符串?我可以找到很多关于通过带有rails的SSL连接提供内容的文档,但是在交付之前没有很多关于签署任意内容的文档。
What would the equivalent command be in Ruby on Rails, assuming I have the XML file in a string? I can find alot of documentation about serving content over a SSL connection with rails, but not alot about signing arbitrary content before delivery.
推荐答案
下面的代码行将签署iPhone配置XML配置文件。
Below lines of code will sign the iPhone configuration XML Profile.
ssl_key_str = File.read("/path/to/private.key")
ssl_key = OpenSSL::PKey::RSA.new(ssl_key_str)
ssl_cert_str = File.read("/path/to/certificate.crt")
ssl_cert = OpenSSL::X509::Certificate.new(ssl_cert_str)
profile = File.read("/path/to/profile.mobileconfig")
signed_profile = OpenSSL::PKCS7.sign(ssl_cert, ssl_key, profile, [], OpenSSL::PKCS7::BINARY)
这篇关于使用Ruby on Rails签署iPhone配置XML配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!