Ruby How to Signing iPhone Configuration XML Profile with Ruby on Rails?

jean · 2012年01月16日 · 最后由 sunfjun 回复于 2020年01月21日 · 3685 次阅读

使用 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

最近也在搞这个,也不行,但是 PHP 的 openssl_pkcs7_sign 没问题

我按照这个测试了,是可以用的。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号