使用 openssl 命令行就可以 sign 出正常的.mobileconfig file,但是使用 ruby 却不行
def mobile_config
ssl_key_str = File.read(Rails.root + "site.key")
ssl_key = OpenSSL::PKey::RSA.new(ssl_key_str)
ssl_cert_str = File.read(Rails.root + "site.crt")
ssl_cert = OpenSSL::X509::Certificate.new(ssl_cert_str)
profile = File.read("/Users/zhang/Desktop/no_sign.mobileconfig")
signed_profile = OpenSSL::PKCS7.sign(ssl_cert, ssl_key, profile, [], OpenSSL::PKCS7::BINARY)
send_file signed_profile
end
原理参考了这篇文章 http://www.rootmanager.com/iphone-ota-configuration/iphone-ota-setup-with-signed-mobileconfig.html
在谷歌上搜到一个解决途径,但是不好使 http://stackoverflow.com/questions/4446247/signing-iphone-configuration-xml-profile-with-ruby-on-rails