1. 如果后臺是java,就將私鑰轉(zhuǎn)成PKCS8格式的,轉(zhuǎn)換方法網(wǎng)上一大把,最簡單就是用支付寶官網(wǎng)的 RSA簽名驗簽工具 咯,諾,直接把私鑰弄進來點轉(zhuǎn)PKCS8帶走
專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站設(shè)計服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)阜寧免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了超過千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
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中都有,添加進項目即可。
支付的話一般都是使用第三方的支付接口。如銀聯(lián),支付寶。你可以申請并簽約使用他們的移動端的支付,他們會提供給你基本移動端開發(fā)集成的SDK