1. 如果后台是java,就将私钥转成PKCS8格式的,转换方法网上一大把,最简单就是用支付宝官网的 RSA签名验签工具 咯,诺,直接把私钥弄进来点转PKCS8带走
专注于为中小企业提供成都网站制作、网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业阜宁免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了超过千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
2. 如果后台是非java,就将不能这么干了,这个时候就得把支付宝demo里的RSADataSigner工具里formatPrivateKey方法改改,改成-----BEGIN RSA PRIVATE KEY-----\n 支付宝demo里是-----BEGIN PRIVATE KEY-----\n,END同理
OK 解决
支付宝开放平台的demo地址:
我在集成支付宝SDK的时候遇到两个问题:
第一个问题:rsa.h头文件找不到
解决办法:在building settings里搜索Header Search Paths 添加文件所在路径 $(SRCROOT)/项目名/文件名
第二个问题:
Undefined symbols for architecture arm64:
"_EVP_DecodeBlock", referenced from:
_dataFromBase64String in openssl_wrapper.o
"_BIO_free_all", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
_rsa_verify_with_public_key_pem in openssl_wrapper.o
"_PEM_read_bio_RSA_PUBKEY", referenced from:
_rsa_verify_with_public_key_pem in openssl_wrapper.o
"_RSA_verify", referenced from:
_rsa_verify_with_public_key_pem in openssl_wrapper.o
"_BIO_new", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
_rsa_verify_with_public_key_pem in openssl_wrapper.o
"_EVP_EncodeBlock", referenced from:
_base64StringFromData in openssl_wrapper.o
"_PEM_read_bio_RSAPrivateKey", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
"_RSA_check_key", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
"_SHA1", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
_rsa_verify_with_public_key_pem in openssl_wrapper.o
(maybe you meant: __Z24alisec_crypto_SHA1_blockP26alisec_crypto_shastate_st_Pmi)
"_RSA_sign", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
"_BIO_ctrl", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
_rsa_verify_with_public_key_pem in openssl_wrapper.o
"_BIO_s_file", referenced from:
_rsa_sign_with_private_key_pem in openssl_wrapper.o
_rsa_verify_with_public_key_pem in openssl_wrapper.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这是缺少libcrypto.a和libssl.a文件引起的,这两个文件在支付宝的demo中都有,添加进项目即可。
支付的话一般都是使用第三方的支付接口。如银联,支付宝。你可以申请并签约使用他们的移动端的支付,他们会提供给你基本移动端开发集成的SDK