背景

银联在线支付本身为开发人员提供了测试环境,但是在某些项目组中,无法连接外部网络,这样就给需要开发银联在线支付的人员造成了一个比较头疼的问题。

通过对银联在线支付SDK研究,银联支付5.0.0版(即报文中version=5.0.0)采用RSA非对称数字证书签名的方式进行报文合法性校验,故决定实现银联在线支付平台仿真端,为不能够连接外网,而又需要调试银联在线支付的开发人员,提供另外一种途径。

目标

  1. 实现银联在线支付5.0.0版,数字签名证书生成
  2. 实现银联在线支付5.0.0版仿真端,消费类交易(支付/付款),退货类交易(退款),交易状态查询交易

RSA非对称数字证书生成

操作系统:Ubuntu 16.04

lsb_release -a[回车]
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial

使用工具:OpenSSL

openssl version[回车]
OpenSSL 1.0.2g  1 Mar 2016

新建证书目录:/program/rsa_cert/

注:以下为生成证书的步骤,按步骤执行即可

一、生成CA(Certificate Authority)证书

1、生成CA证书key

openssl genrsa -des3 -out edu1t1_ca.key 2048[回车]
Generating RSA private key, 2048 bit long modulus
........................................+++
..........+++
e is 65537 (0x10001)
Enter pass phrase for edu1t1_ca.key:(输入密码)
Verifying - Enter pass phrase for edu1t1_ca.key:(输入确认密码)

2、生成CA证书

openssl req -new -x509 -days 365 -key edu1t1_ca.key -out edu1t1_ca.crt[回车]
Enter pass phrase for edu1t1_ca.key:(输入证书密码)
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) [AU]:CN(国家)
State or Province Name (full name) [Some-State]:TIANJIN(州/省)
Locality Name (eg, city) []:NANKAI(位置)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:EDU1T1(组织)
Organizational Unit Name (eg, section) []:EDU1T1(单位)
Common Name (e.g. server FQDN or YOUR name) []:PAYPLATFORM(常用名)
Email Address []:abc@abc.com(电子邮箱地址)

二、生成RSA签名/验签证书

1、生成私钥

openssl genrsa -out edu1t1_sign.key 2048[回车]
Generating RSA private key, 2048 bit long modulus
..........+++
......+++
e is 65537 (0x10001)

2、生成服务器端签名请求文件

openssl req -new -key edu1t1_sign.key -out edu1t1_sign.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) [AU]:CN(国家)
State or Province Name (full name) [Some-State]:TIANJIN(州/省)
Locality Name (eg, city) []:NANKAI(位置)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:EDU1T1(组织)
Organizational Unit Name (eg, section) []:EDU1T1(单位)
Common Name (e.g. server FQDN or YOUR name) []:PAYPLATFORM(常用名)
Email Address []:abc@abc.com(电子邮件地址)Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:000000(输入)
An optional company name []:EDU1T1(输入)

3、利用 CA 进行签名证书

将文件 /usr/lib/ssl/openssl.cnf 拷贝至 /program/rsa_cert 下,使用VI编辑器打开并进行如下内容修改(标红部分)

####################################################################
    [ ca ]
    default_ca    = CA_default        # The default ca section
    ####################################################################
    [ CA_default ]
    dir        = ./certs                                # Where everything is kept
    certs        = $dir/certs                        # Where the issued certs are kept
    crl_dir        = $dir/crl                        # Where the issued crl are kept
    database    = $dir/index.txt                # database index file.
    #unique_subject    = no                    # Set to 'no' to allow creation of
                                                            # several ctificates with same subject.

new_certs_dir    = $dir/newcerts        # default place for new certs.

在 /program/rsa_cert 下新建目录 certs

在certs下新建,目录newcerts,文件index.txt和文件serial(serial文件中需要输入一串十六进制数字串,作为Serial Number)

注意,Ubuntu18.04下,自带openssl 1.1.1,可能会出现以下错误(对应解决方法如下)

错误一:Can't load ~/.rnd into RNG,解决方法,在当前用户根目录下执行如下命令:

openssl rand -writerand .rnd[回车]

错误二:Can't open ./certs/index.txt.attr for reading, No such file or directory,解决方法为,在certs下,新建 index.txt.attr 文件

错误三:error while loading serial number,解决方法,执行如下命令:

echo 00 > serial[回车]

如果一切正常,则如下命令可以正常执行,并得到如下:结果

openssl ca -in edu1t1_sign.csr -out edu1t1_sign.crt -keyfile edu1t1_ca.key -cert edu1t1_ca.crt -days 365 -config openssl.cnf[回车]
Using configuration from openssl.cnf
Enter pass phrase for edu1t1_ca.key:(输入证书密码)
Check that the request matches the signature
Signature ok
Certificate Details:Serial Number: 1193046 (0x123456)ValidityNot Before: Mar 23 07:52:23 2018 GMTNot After : Mar 23 07:52:23 2019 GMTSubject:countryName               = CNstateOrProvinceName       = TIANJINorganizationName          = EDU1T1organizationalUnitName    = EDU1T1commonName                = PAYPLATFORMemailAddress              = abc@abc.comX509v3 extensions:X509v3 Basic Constraints: CA:FALSENetscape Comment: OpenSSL Generated CertificateX509v3 Subject Key Identifier: 8C:00:0D:9B:C6:BD:A8:E8:53:FC:61:61:33:C5:2B:E9:4F:AD:D6:6AX509v3 Authority Key Identifier: keyid:B6:A4:16:2D:B0:8D:2A:27:70:8D:27:C5:B4:57:07:EB:8E:40:CA:E4Certificate is to be certified until Mar 23 07:52:23 2019 GMT (365 days)
Sign the certificate? [y/n]:y(输入y)1 out of 1 certificate requests certified, commit? [y/n]y(输入y)
Write out database with 1 new entries
Data Base Updated

得到 pfx 格式的私钥

openssl pkcs12 -export -out edu1t1_sign.pfx -inkey edu1t1_sign.key -in edu1t1_sign.crt[回车]
Enter Export Password:(输入证书密码)
Verifying - Enter Export Password:(输入确认密码)

这次输入的密码为打开pfx证书时的密码,建议为000000(因为银联的测试证书默认密码为000000,这样可以尽量减少商户端配置变更)

得到 cer 格式的公钥

openssl x509 -inform pem -in edu1t1_sign.crt -outform der -out edu1t1_validate.cer[回车]

至此,银联在线支付5.0.0版签名(edu1t1_sign.pfx)和验签(edu1t1_validate.cer)证书生成完毕(已生成证书下载)。

使用Spring boot搭建银联在线支付仿真端

在此不再详述项目搭建步骤,仅提供两种形态的工程下载:

工程一下载:打包后的工程,可在Redhat Linux下运行,附工程的操作和运行说明(即readme文件内容),可直接下载用来做项目组开发银联在线支付的仿真端。

工程二下载:完整的源码下载(Maven工程),仅供学习与技术交流使用。

银联在线支付5.0.0版-仿真端相关推荐

  1. 银联在线php支付接口,ecshop银联在线支付接口插件(官方版)

    分享一个银联在线支付(UPOP)ecshop支付接口的插件,亲自用过.你只需放到ec对应的目录,然后进到后台"支付方式"页面安装就能调用了.希望能对你有用!! 此插件在ecshop ...

  2. java银联在线支付开发_银联在线支付案例代码

    [实例简介] 银联在线支付的测试案例代码 [实例截图] [核心代码] PayOnLine └── PayOnLine ├── src │   ├── acp_sdk.properties │   └─ ...

  3. Firefox全面兼容中国银联“在线支付”

    http://www.linuxdiyf.com/viewarticle.php?id=202865 来源: 驱动之家 昨日下午,中国银联正式推出了"在线支付"和"互联网 ...

  4. “银联在线支付”签约无需任何条件,个人也可以完成签约

    申请条件:"银联在线支付"签约无需任何条件,个人也可以完成签约,只需要您购买我们开通好的企业支付宝,账户您自己管理,资金您自己操作(QQ3.0.5.7.1.0.4.3.9),或您也 ...

  5. 银联在线支付对接流程以及签名算法

    银联在线支付 简介 银联在线支付支持PC网关.手机SDK.WAP网关.云闪付等多种支付场景,其中云闪付产品可以完美支持ApplePay.Samsung Pay.Huawei Pay等市面上常见的手机厂 ...

  6. php 银行支付通道_PHP银联在线支付接口的开发实例

    本文主要和大家分享PHP银联在线支付接口的开发实例,希望能帮助到大家. 1. 登录银联自助化测试平台(登陆地址:open.unionpay.com),登录后,点击我的产品,如下:点击右方需要测试的接口 ...

  7. ECSHOP 银联在线支付 PHP 银联商务

    <?php/*** ECSHOP 银联在线支付* ======================================================================== ...

  8. 银联在线支付从upop切换到全渠道的交易流程

    2019独角兽企业重金招聘Python工程师标准>>> 银联在线支付在2014年重建了一个新的系统(全渠道acp)代替老系统(upop),并2014-2015期间将所有商户从upop ...

  9. PHP银联在线支付接口开发日志

    银联在线支付接口开发日志 1. 登录银联自助化测试平台(登陆地址:open.unionpay.com),登录后,点击我的产品,如下:点击右方需要测试的接口,本例以 手机网页支付(WAP支付)为例. 2 ...

最新文章

  1. 对话谢宝友:搞真正自研的国产操作系统,而不是伪创新
  2. 常用24个方法有效优化ASP.NET的性能
  3. windows7下GithubDesktop和极域学生客户端冲突导致无法正常打开解决方案
  4. java对密码进行加密的方法_如何在JAVA中使用MD5加密对密码进行加密
  5. oracle数据库link格式,Oracle创设DB Link
  6. [翻译] RDVTabBarController
  7. Git建立远程代码仓库和本地代码仓库
  8. 修改时间日期 linux,Linux查看和修改时间、日期
  9. 缓存 ASP.NET 页
  10. Java添加多行数据到mysql中_Java:使用PreparedStatement将多行插入到MySQL中
  11. C语言之生成汇编代码(十)
  12. 使 32 位程序使用大于 2GB 的内存
  13. idea git配置好之后无法看到已修改的文件解决方法
  14. Nsight中给工程添加include目录
  15. Windows系统下长ping记录日志小工具
  16. 怎么用spss做冗余分析_【攻略】手把手教你怎么用SPSS做统计分析
  17. ico图标制作的在线工具
  18. mockjs随机生成浅色图片 | 十六进制颜色码调色大法 | 莫兰迪色系
  19. java 公共方法是什么意思_在java中公共/私有/其他方法的含义是什么意...
  20. mysql多表关联查询慢_mysql数据库多表关联查询的慢SQL优化

热门文章

  1. 不小心误删注册表exe,所有exe程序无法运行
  2. HTMLlesson1.1
  3. 【老生谈算法】matlab实现多种滤波器算法源码——多种滤波器
  4. 顺序结构,选择结构和循环结构
  5. 【Educational Codeforces Round 6A】【水题】Professor GukiZ's Robot 曼哈顿距离
  6. class 5 搭建个人 Leanote 云笔记本
  7. 有无可能在非IOS系统上实现苹果为网易/腾讯邮箱做的实时推送
  8. c语言集合运算有菜单,怎样用C语言实现集合运算
  9. Stay foolish stay hungry
  10. C语言吞食鱼,大鱼吃小鱼.cpp · 2019春C语言/programming-1 - Gitee.com