我有一个Rails应用程序,在使用Paypal进行交易之前加载了许多RSA证书.在我的开发机器上,这些证书是从文件系统中的文件中读取的,但是因为Heroku(我用于处理)很大程度上是只读的,所以我无法上传这些文件所以我猜我必须要从配置变量中读取证书(参见Heroku Config Vars).
因为证书由多行数据组成,所以我不确定如何将它们设置为变量,即使这是可能的.有谁知道我怎么做或者能够建议另一种方法?
非常感谢,艾迪
通过传递.pem文件使用OpenSSL :: PKey :: RSA模块构建公钥时,响应的原因是什么:
OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key:: nested asn1 error
from /Users/Matt/projects/placepop/lib/apn.rb:48:in `initialize'
from /Users/Matt/projects/placepop/lib/apn.rb:48:in `new'
from /Users/Matt/projects/placepop/lib/apn.rb:48:in `open'
from (irb):1
Run Code Online (Sandbox Code Playgroud)
这是来源:
cert = File.join(rails_root, 'config', 'apns', 'sandbox-cert.pem')
APN_CONFIG = { :delivery => {
:host => 'gateway.sandbox.push.apple.com',
:cert => cert,
:passphrase => "",
:port => 2195 },
:feedback => {
:host => 'feedback.sandbox.push.apple.com',
:port => 2196,
:passphrase => "",
:cert => cert} }
options = APN_CONFIG[:delivery].merge(options)
cert = File.read(options[:cert])
ctx = OpenSSL::SSL::SSLContext.new
ctx.key = OpenSSL::PKey::RSA.new(cert, …Run Code Online (Sandbox Code Playgroud) 我想知道如何在我的C源文件中使用OpenSSL库生成RSA私钥.我知道如何使用terminal命令生成它.
实际上我的server.c文件将生成一个私钥并发送到client.c请尽可能帮助我一些源代码,否则任何帮助将不胜感激.
我正在研究Linux机器.