win2008R2/Win7启用TLS 1.2实践

因为项目须要用到PayPal, 就去研究了下paypal,可是PayPal须要TLS 1.2, 就google了一把,这里把整个流程写下来php

准备

Tips:git

  1. 公司服务器总体结构是 windows 2008R2 + IIS + PHPgithub

  2. 使用PhpStudy,使用其余的也没问题apache

说一下win7也能够, 能够拿来作测试.若是使用win7来测试,须要控制面板>程序和功能>启用和关闭windows组件 开启IIS组件(怎样开启,自行google)windows

若是服务器是apache,只须要使用高版本的php_openssl扩展就好了,选用apche+PHP5.5n我已经确承认用, php5.6会报错找不到某某加密函数api

PayPal的需求是bash

  1. PHP_VERSION >= 5.3服务器

  2. php_curl, php_openssl 必须启用composer

  3. composer(怎样安装参考http://www.phpcomposer.com)curl

phpStudy切换到 IIS7/8 + PHP 5.5n

这里说一声, 选这PHP 5.5以前的版本, 因为openssl扩展的版本太低, 可能不支持, 我选5.4就不支持

下载PayPal的sdk

地址:https://github.com/paypal/Pay...
克隆到你的网站目录
打开git bash

git clone https://github.com/paypal/PayPal-PHP-SDK.git paypal
cd paypal
composer update

其实就是把代码下载下来, 复制到paypal目录, 而后在目录在命令行执行composer update

配置TLS1.2

分为2步, 添加TLS配置和禁用老的SSL版本

配置TLS1.2

提供两种方法, 选择其中一种就好了

手动设置

找到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols右键->新建->项->新建TLS 1.1,TLS 1.2
TLS 1.1和TLS 1.2 右键->新建->项->新建Server, Client
在新建的Server和Client中都新建以下的项(DWORD 32位值), 总共4个

DisabledByDefault [Value = 0]
Enabled [Value = 1]

如图

直接导入注册表文件

以下, 是我从个人注册表里面导出来的, 新建文本文件, 后缀名改成reg就好了, 双击导入

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000000
"Enable"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"DisabledByDefault"=dword:00000000
"Enable"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enable"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault "=dword:00000000
"Enable"=dword:00000001

禁用老SSL配置

打开HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client 配置以下

DisabledByDefault [Value = 0]
Enabled [Value = 0]

测试

打开网站, 个人是部署到局域网的,

192.168.1.99/paypal/sample


若是你配置了apiContent是有数据出来的,我没有配置, 因此就只是No Data

相关文章
相关标签/搜索