Windows Server 2008 R2 中IIS启用TLS 1.2

由于项目需要用到PayPal, 就去研究了下PayPal,但是PayPal需要TLS 1.2, 就Google了一把,这里把整个流程写下来

准备

Tips:

  1. 公司服务器整体结构是 Windows Server 2008 R2+ IIS + PHP

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

说一下win7也可以, 可以拿来做测试.如果使用Win7来测试,需要控制面板>程序和功能>启用和关闭Windows组件 开启IIS组件(怎样开启,自行Google)

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

PayPal的需求是

  1. PHP_VERSION >= 5.3

  2. php_curl, php_openssl 必须启用

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

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

猜你喜欢

转载自www.linuxidc.com/Linux/2017-04/142744.htm