CN112636900A - 一种基于md5加密的http/https接口安全校验方法 - Google Patents

一种基于md5加密的http/https接口安全校验方法 Download PDF

Info

Publication number
CN112636900A
CN112636900A CN202011447768.5A CN202011447768A CN112636900A CN 112636900 A CN112636900 A CN 112636900A CN 202011447768 A CN202011447768 A CN 202011447768A CN 112636900 A CN112636900 A CN 112636900A
Authority
CN
China
Prior art keywords
platform
party
token
time
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011447768.5A
Other languages
English (en)
Inventor
于东方
罗义斌
杨冰
朱学坤
陈剑
黄嘉诚
孙力斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Lianchuang Internet Technology Co ltd
Original Assignee
Nanjing Lianchuang Internet Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Lianchuang Internet Technology Co ltd filed Critical Nanjing Lianchuang Internet Technology Co ltd
Priority to CN202011447768.5A priority Critical patent/CN112636900A/zh
Publication of CN112636900A publication Critical patent/CN112636900A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/02Network architectures or network communication protocols for network security for separating internal from external traffic, e.g. firewalls
    • H04L63/0227Filtering policies
    • H04L63/0236Filtering by address, protocol, port number or service, e.g. IP-address or URL
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/083Network architectures or network communication protocols for network security for authentication of entities using passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0869Network architectures or network communication protocols for network security for authentication of entities for achieving mutual authentication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0876Network architectures or network communication protocols for network security for authentication of entities based on the identity of the terminal or configuration, e.g. MAC address, hardware or software configuration or device fingerprint
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/321Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving a third party or a trusted authority
    • H04L9/3213Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving a third party or a trusted authority using tickets or tokens, e.g. Kerberos
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3297Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving time stamps, e.g. generation of time stamps

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Power Engineering (AREA)
  • Computer And Data Communications (AREA)

Abstract

一种基于MD5加密的HTTP/HTTPS接口安全校验方法,第三方通过http/https欲接入互联网传播时,接入互联网前要向服务器申请appkey以及secret;第三方每次接入互联网前的请求都带上当前时间戳参数time,平台需要校验请求的时效性同时支持有效时间内操作的幂等性;第三方遵照平台约定规则生成token,并作为接口调用的请求参数传入平台进行校验;平台对第三方传入的token参数值进行验证。

Description

一种基于MD5加密的HTTP/HTTPS接口安全校验方法
技术领域
本发明涉及IT/计算机网络技术领域,尤其是MD5技术的应用。
背景技术:
HTTP/HTTPS接口是互联网各系统之间对接的重要方式之一,使用HTTP/HTTPS接口开发和调用都很方便,也是被大量采用的方式,它可以让不同系统之间实现数据的交换和共享。由于HTTP/HTTPS接口开放在互联网上,所以我们就需要有一定的安全措施来保证接口安全。基于以上原因,采用以下方法解决接口安全性问题。
主要从两个方面考虑:1.验证调用者的合法身份;2.保证数据传输的安全性;http是超文本传输协议,信息是明文传输;https则是具有安全性的ssl加密传输协议(SSL是Netscape公司所提出的安全保密协议,非对称密钥加密)。https协议则需要到ca申请证书。
基于以上两点安全性的考虑,接口也可采用token认证的方式来实现,主要包括针对不同第三方的接入分配不同的appkey以及secret来进行身份认证;利用一定规则生成的token值来防止请求过程中的参数篡改;利用time时间戳的校验可以在一定时间范围内防止调用方恶意的重复请求风险。
现有有MD5加密是指让大容量信息在用数字签名软件签署私人密匙前被"压缩"成一种保密的格式(就是把一个任意长度的字节串变换成一定长的大整数)。不管是MD2、MD4还是MD5,它们都需要获得一个随机长度的信息并产生一个128位的信息摘要。MD5以512位分组来处理输入文本,每一分组又划分为16个32位子分组。算法的输出由四个32位分组组成,将它们级联形成一个128位散列值。首先填充消息使其长度恰好为一个比512位的倍数仅小64位的数。填充方法是附一个1在消息后面,后接所要求的多个0,然后在其后附上64位的消息长度(填充前)。这两步的作用是使消息长度恰好是512位的整数倍(算法的其余部分要求如此),同时确保不同的消息在填充后不相同。
MD5步骤是,四个32位变量A、B、C、D初始化:称为链接变量(chaining variable),接着进行算法的主循环,循环的次数是消息中512位消息分组的数目。将上面四个变量复制到另外的变量中:A到a,B到b,C到c,D到d。每次操作对a,b,c和d中的其中三个作一次非线性函数运算,然后将所得结果加上第四个变量,文本的一个子分组和一个常数。再将所得结果向右环移一个不定的数,并加上a,b,c或d中之一。最后用该结果取代a,b,c或d中之一。
发明内容
本发明目的是,提出一种基于MD5加密的HTTP/HTTPS接口安全校验方法。
本发明的技术方案是,一种基于MD5加密的HTTP/HTTPS接口安全校验方法,第三方通过http/https欲接入互联网传播时,接入互联网前要向(服务器)平台申请appkey以及secret;
appkey:准用户ID,唯一标识第三方应用,方便服务器平台统计与维护;
secret:密钥,用于生成服务器平台校验的token值;
第三方每次接入互联网前的请求都带上当前时间戳参数time,这里的时间戳是指UTC时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。平台需要校验请求的时效性(平台只处理有效时间范围内的请求,有效时间默认为5分钟)同时支持有效时间内操作的幂等性;第三方遵照平台约定规则生成token,并作为接口调用的请求参数传入平台进行校验;平台对第三方传入的token参数值进行验证。根据本申请后述的token生成示例;平台侧根据入参生成一个平台侧的token与入参中的token进行比对;规则可以根据需要自己定义;用相同参数+密钥生成token后与入参的token比对。
平台进行校验指MD5校验。(服务器)平台提供MD5算法;对入参进行排序+密钥进行MD5计算得到token值。
有益效果:由于采用时间戳参数time,平台需要校验请求的时效性(平台只处理有效时间范围内的请求,有效时间默认为5分钟)同时支持有效时间内操作的幂等性;这是MD5加密的基本方法和过程,在编程中一个幂等操作的特点是其任意多次执行所产生的影响均与一次执行的影响相同。幂等函数,或幂等方法,是指可以使用相同参数重复执行,并能获得相同结果的函数。本发明能有效过滤重复请求,可以在https基础上进一步保证接口安全(https协议则需要到ca申请证书)。整体架构设计:第三方接入前要向平台申请appkey以及secret;
appkey:类似用户ID,唯一标识第三方应用,方便平台统计与维护;
secret:密钥,用于生成平台校验的token值;
第三方每次请求都带上当前时间戳参数time,这里的时间戳是指UTC时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。平台需要校验请求的时效性(平台只处理有效时间范围内的请求,有效时间默认为5分钟)同时支持有效时间内操作的幂等性;
第三方遵照平台约定规则生成token,并作为接口调用的请求参数传入平台进行校验;平台对第三方传入的token参数值进行验证;Token生成示例中已提供post和get请求方式的token生成规则,双方生成规则相同。
本发明架构具有如下整体特性,架构设计不依赖于其他第三方组件,实现简单,同时双向验证。
附图说明
图1为本发明按约定规则生成token的流程图。
具体实施方式
本发明架构实现方法:
1.token生成规则
token=MD5(请求URI+参数串+secret);
参数串包括:接口业务参数、必传参数appkey和time。
注:加密的字符串统一采用UTF-8编码。
2.HTTP/HTTPS请求中GET方式
token生成后把token参数拼接在参数串(包括接口业务参数、必传参数appkey和time)后即可。
示例:
Figure BDA0002825408310000021
API接口:http://IP:PORT/web/api/get
Figure BDA0002825408310000022
接口业务参数:a=xx1、c=xx2、b=xx3
Figure BDA0002825408310000023
appkey:D30F8B3D21F70AE3A991FBFBB0923329
Figure BDA0002825408310000024
secret:6C4D6BD4F324DCF8F72F4F5A362F17F9
Figure BDA0002825408310000025
time:1605599896781
Figure BDA0002825408310000026
token=MD5(“/web/api/get”+“a=xx1&appkey=D30F8B3D21F70AE3A991FBFBB0923329&b=xx3&c=xx2&time=1605599896781”+“6C4D6BD4F324DCF8F72F4F5A362F17F9”);
Figure BDA0002825408310000027
请求URL地址:http://IP:PORT/web/api/get?a=xx1&appkey=D30F8B3D21F70AE3A991FBFBB0923329&b=xx3&c=xx2&time=1605599896781&token=
注:MD5生成token中参数串中的接口业务参数顺序请按参数名ascii码升序排序。
3.HTTP/HTTPS请求中POST方式
token生成后把token参数及值拼接在POST请求URL后面即可,其他参数以json格式提交。
注:不是拼接在POST数据的JSON串上。
示例:
Figure BDA0002825408310000031
API接口:http://IP:PORT/web/api/post
Figure BDA0002825408310000032
接口业务参数:a=test1、c=test2、b=test3
Figure BDA0002825408310000033
appkey:D30F8B3D21F70AE3A991FBFBB0923329
Figure BDA0002825408310000034
secret:6C4D6BD4F324DCF8F72F4F5A362F17F9
Figure BDA0002825408310000035
time:1605599896781
Figure BDA0002825408310000036
POST数据的JSON串生成如下:
{"a":"test1","appkey":"D30F8B3D21F70AE3A991FBFBB0923329","b":"test3","c":"test2","time":"1605599896781"}
token=MD5(“/web/api/post”+“{"a":"test1","appkey":"D30F8B3D21F70AE3A991FBFBB0923329","b":"test3","c":"test2","time":"1605599896781"}”+“6C4D6BD4F324DCF8F72F4F5A362F17F9“);
Figure BDA0002825408310000037
请求URL地址:http://IP:PORT/web/api/post?token=MD5生成token中参数串中的接口业务参数顺序请按参数名ascii码升序排序。

Claims (2)

1.一种基于MD5加密的HTTP/HTTPS接口安全校验方法,其特征是,第三方通过http/https欲接入互联网传播时,接入互联网前要向(服务器)平台申请appkey以及secret;
appkey:准用户ID,唯一标识第三方应用,方便服务器平台统计与维护;
secret:密钥,用于生成服务器平台校验的token值;
第三方每次接入互联网前的请求都带上当前时间戳参数time,这里的时间戳是指UTC时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。平台需要校验请求的时效性,平台只处理有效时间范围内的请求,有效时间默认为5分钟,同时支持有效时间内操作的幂等性;第三方遵照平台约定规则生成token,并作为接口调用的请求参数传入平台进行校验;平台对第三方传入的token参数值进行验证。
2.根据权利要求1所述的基于MD5加密的HTTP/HTTPS接口安全校验方法,其特征是,所述平台校验指MD5校验。
CN202011447768.5A 2020-12-09 2020-12-09 一种基于md5加密的http/https接口安全校验方法 Pending CN112636900A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011447768.5A CN112636900A (zh) 2020-12-09 2020-12-09 一种基于md5加密的http/https接口安全校验方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011447768.5A CN112636900A (zh) 2020-12-09 2020-12-09 一种基于md5加密的http/https接口安全校验方法

Publications (1)

Publication Number Publication Date
CN112636900A true CN112636900A (zh) 2021-04-09

Family

ID=75310298

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011447768.5A Pending CN112636900A (zh) 2020-12-09 2020-12-09 一种基于md5加密的http/https接口安全校验方法

Country Status (1)

Country Link
CN (1) CN112636900A (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117952614A (zh) * 2024-03-14 2024-04-30 深圳市金政软件技术有限公司 支付防重方法、装置、终端设备和可读存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108632204A (zh) * 2017-03-17 2018-10-09 网宿科技股份有限公司 Http接口访问权限验证方法、系统、及服务器
CN108650093A (zh) * 2018-03-30 2018-10-12 深圳市富途网络科技有限公司 一种基于幂等性的接口实现方法
CN111935164A (zh) * 2020-08-14 2020-11-13 天元大数据信用管理有限公司 一种https接口请求方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108632204A (zh) * 2017-03-17 2018-10-09 网宿科技股份有限公司 Http接口访问权限验证方法、系统、及服务器
CN108650093A (zh) * 2018-03-30 2018-10-12 深圳市富途网络科技有限公司 一种基于幂等性的接口实现方法
CN111935164A (zh) * 2020-08-14 2020-11-13 天元大数据信用管理有限公司 一种https接口请求方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117952614A (zh) * 2024-03-14 2024-04-30 深圳市金政软件技术有限公司 支付防重方法、装置、终端设备和可读存储介质

Similar Documents

Publication Publication Date Title
US9124576B2 (en) Configuring a valid duration period for a digital certificate
US8799981B2 (en) Privacy protection system
KR102124413B1 (ko) 아이디 기반 키 관리 시스템 및 방법
EP2959631B1 (en) Verification system and method with extra security for lower-entropy input records
CN108810029A (zh) 一种微服务架构服务间鉴权系统及优化方法
US20030093678A1 (en) Server-side digital signature system
US20090307486A1 (en) System and method for secured network access utilizing a client .net software component
CN104935568A (zh) 一种面向云平台接口鉴权签名方法
Shang et al. Identity-based dynamic data auditing for big data storage
US9369459B2 (en) Method of establishing secure groups of trusted contacts with access rights in a secure communication system
WO2009115017A1 (zh) 网络认证服务系统和方法
CN111698225A (zh) 一种适用于电力调度控制系统的应用服务认证加密方法
CN113079022B (zh) 一种基于sm2密钥协商机制的安全传输方法和系统
CN108777673B (zh) 一种在区块链中进行双向身份认证方法
JP2007318806A (ja) 移動ネットワーク環境におけるデータトラフィックの保護方法
CN112636900A (zh) 一种基于md5加密的http/https接口安全校验方法
Persiano et al. User privacy issues regarding certificates and the TLS protocol: the design and implementation of the SPSL protocol
Tang et al. A lightweight two-way authentication scheme between communication nodes for software defined optical access network
De Backere et al. Design of a security mechanism for RESTful Web Service communication through mobile clients
CN116318654A (zh) 融合量子密钥分发的sm2算法协同签名系统、方法及设备
CN116232632A (zh) 移动端sslvpn安全隧道应用方法及系统
CN111935164B (zh) 一种https接口请求方法
Gionta et al. iHTTP: Efficient authentication of non-confidential HTTP traffic
CN115529176A (zh) 一种多客户端接口验签管理方法
Chen et al. Micro-application security authentication based on key agreement hybrid encryption algorithm

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210409