融360SDK处理

本文介绍如何使用openssl工具生成RSA密钥对,并详细展示了iOS端如何将私钥转换为p12格式,以及如何在代码中利用这些密钥进行配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

相关链接

通过openssl工具生成RSA的公钥和私钥:

Snip20180111_9.png

第一步:生成私钥

openssl genrsa -out rsa_private_key.pem 1024

注:可以在天机开发平台测试私钥是否正确,https://tianji.rong360.com/open/testapi

第二步:生成公钥

openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem

其中:

(1)android 端接入时,需将RSA私钥转换成PKCS8格式
openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out rsa_private_key_pkcs8.pem

(2)iOS端接入时,需将pem私钥转换成p12格式
如私钥文件为rsa_private_key.pem,私钥文件转p12时,需在终端输入如下命令:

①生成一个csr文件,并输入配置信息【可随便输入配置信息】:
openssl req -new -key rsa_private_key.pem -out rsacert.csr

Country Name (2 letter code) [AU]:CN

State or Province Name (full name) [Some-State]:beijing

Locality Name (eg, city) []:beijing

Organization Name (eg, company) [Internet Widgits Pty Ltd]:Rong360

Organizational Unit Name (eg, section) []:com

Common Name (e.g. server FQDN or YOUR name) []:R360

Email Address []:whj5484138@gmail.com

Please enter the following ‘extra’ attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:
②生成证书并且签名,有效期10年:
openssl x509 -req -days 3650 -in rsacert.csr -signkey rsa_private_key.pem -out rsacert.crt 
③生成p12文件:
openssl pkcs12 -export -out private.p12 -inkey rsa_private_key.pem -in rsacert.crt

生产p12过程

zetafindeMacBook-Air:~ zetafin$ openssl req -new -key rsa_private_key.pem -out rsacert.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) []:CN
State or Province Name (full name) []:shanghai
Locality Name (eg, city) []:shanghai
Organization Name (eg, company) []:JieTa
Organizational Unit Name (eg, section) []:com
Common Name (eg, fully qualified host name) []:JieTa
Email Address []:feiliyaailiya1@icloud.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
zetafindeMacBook-Air:~ zetafin$ openssl x509 -req -days 3650 -in rsacert.csr -signkey rsa_private_key.pem -out rsacert.crt
Signature ok
subject=/C=CN/ST=shanghai/L=shanghai/O=JieTa/OU=com/CN=JieTa/emailAddress=feiliyaailiya1@icloud.com
Getting Private key
zetafindeMacBook-Air:~ zetafin$ openssl pkcs12 -export -out private.p12 -inkey rsa_private_key.pem -in rsacert.crt
Enter Export Password:
Verifying - Enter Export Password:
项目相关代码

    public func initCrawl(){
        let keyPath = Bundle.main.path(forResource: "private", ofType: "p12")
        let keyData = NSData.init(contentsOfFile: keyPath!)
        print("keyData ********** \(String(describing: keyData))")
        RDPCrawlerManager.configOptionalAppName("appName")

        #if APPTEST
            //沙箱环境
            RDPCrawlerManager.setIsDebug(false)
            RDPCrawlerManager.configAppId("沙箱环境appid", delegate: self, privateKey: keyData! as Data)
        #else
            //正式环境
            RDPCrawlerManager.setIsDebug(true)
            RDPCrawlerManager.configAppId("正式环境appid", delegate: self, privateKey: keyData! as Data)
        #endif
    }
            let dic = data as! NSDictionary
            let crawlType = dic["type"] as! NSString
            guard  let mobile = dic["mobile"] as? String , let name = dic["fullName"] as? String,let idcard = dic["nricNo"] as? String else{
                return
            }
            let dataDic = ["real_name":name,"id_card":idcard,"cellphone":mobile] as [String : Any]

            let config: RDPC_Config = RDPC_Config()
            config.phone = mobile
            config.canEditPhone = true
            config.idNo = idcard
            config.addtionParams = dataDic

            if crawlType == "alipay"{ // 调取支付宝
                config.taskId = "11111"
                config.type = .rdpCrawlerTypeAlipay
            }else if(crawlType == "ec"){ // 调取邮箱
                config.taskId = "22222"
                config.type = .rdpCrawlerTypeEmail
            }else if(crawlType == "taobao"){ // 调取淘宝
                config.taskId = "33333"
                config.type = .rdpCrawlerTypeTaobao
            }else if(crawlType == "mobile"){ // 调取运营商
                config.type = .rdpCrawlerTypeOperator
                config.taskId = "44444"
            }
            // 启动抓取
            RDPCrawlerManager.startCrawler(config)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值