Rails 调用微信红包接口的时候提示 “CA 证书出错,请登录微信支付商户平台下载证书”

gerry1004 · July 06, 2015 · Last by Thomastar replied at April 17, 2018 · 7729 hits

情况

在调用微信现金红包接口的时候,发送请求,老是提示“CA 证书出错,请登录微信支付商户平台下载证书”,查了好多资料,找不到解决办法。 谁能给点提示,或者资料看一下。

补充:证书已经下到了。

def post_xml(action, xml)
apiclient_cert = cert_pem_to_x509(self.api_client_cert) apiclient_key = key_pem_to_rsa(self.api_client_key) conn = Faraday.new(ssl: {client_cert: apiclient_cert, client_key: apiclient_key}, headers: {'Content-Type' => 'application/xml'}) do |faraday| faraday.adapter Faraday.default_adapter end

res = conn.post(pay_url(action), xml, {'Content-Type' => 'application/xml'})

res end

def cert_pem_to_x509(cert_pem) cert_x509 = OpenSSL::X509::Certificate.new cert_pem end

def key_pem_to_rsa(key_pem) key_rsa = OpenSSL::PKey::RSA.new key_pem end

@gerry 谢谢,这个问题已经解决了,感觉还是找资料的时候不够仔细。看漏了。不过还是谢谢你,涨姿势了。

cert_pem 这个是路径还是?

You need to Sign in before reply, if you don't have an account, please Sign up first.