




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、运营支持部apache用户配置手册apache(https)配置手册拟制:tipyluo日期:yyyy/mm/dd审核:日期:yyyy/mm/dd项目名称:项目经理:深圳腾讯计算机系统有限公司版权所有 不得复制修订记录版本号发布日期编制人审核人/批准人修改章节号1.02005-06-23tipyluo创建目 录1概述42解决方案(原理)42.1ssl握手协议和通讯53系统配置要求53.1硬件要求63.2软件要求64安装流程64.1安装前准备64.2执行安装6安装apache64.3安装后验证74.4安装过程常见问题解决75系统配置75.1调整黙认选项75.2虚拟机配置75.3单向认证https
2、配置85.4双向认证https配置115.5自建根证书125.6服务器证书签署125.7客户端证书签署136系统使用及维护137faq137.1faq1-xxx138参考资源141 概述互联网技术的普及为人们的生活、工作带来了更多的便利,现在只要你有一台可以上网的电脑,那么足不出户,你只需要动一动鼠标就可以在家轻松实现网上购物、网上结汇帐务、网上股票交易等等原来需要耗费大量时间和精力并且要来回奔波才能完成的事情。然而,我们在享受互联网技术给我们的生活和工作带来的便利的同时,是否想到在虚拟的网络世界中,我们在做每一次网上购物或是网上银行帐务查询时,我们如何保证我们所定的货物,使我们所需求的;我们
3、汇出得钱款能够安全到达指定位置;我们的查询信息能够不被别人窃取。近年来,网上假冒网站进行欺诈的行为已经发生了多起,假冒交易或会员网站,骗取用户资料,假冒银行的网站,盗取用户帐户的事件;更由甚者,在发生自然灾难的时候,假冒慈善网站骗取钱财,可以说恶劣至极。 作为网站的提供方,出发点是为了方便用户,同时在展现自己企业风采的同时,降低与用户沟通的成本然而,假冒网站却给网站的提供者和使用者,都提出以下安全问题,需要认真对待解决: 网站的真实性: 用户访问网站时需要确认网站的真实性,由于互联网的广泛性和开放性,使得互联网上存在很多虚假的网站,如何让用户信任自己访问的网站。 信息的机密性: 现在大量的网上
4、应用需要用户向应用服务器提交一些隐私及机密信息,同时应用服务器也可能向用户返回一些隐私及机密信息,如何确保这些信息的安全。这些问题即是此文档要着重讨论及解决的问题。2 解决方案(原理) 网站安全认证架构图 1. 采用网站安全认证解决方案,通过为网站配置服务器证书(通过ca机构认证签发),可以为网站提供安全、可靠的身份认证方案,用户通过验证网站的服务器证书来判断网站的真实性;2. 通过配置服务器证书将在客户端和服务器之间建立安全通道,确保客户端和服务器之间数据传输的安全; 3. 通过扩展,服务器可以启用双向认证的连接,服务器可以要求客户端提供用户证书,来判断用户的真实身份。 2.1 ssl握手协
5、议和通讯为了便于更好的认识和理解 ssl 协议,这里着重介绍 ssl 协议的握手协议。ssl 协议既用到了公钥加密技术又用到了对称加密技术,对称加密技术虽然比公钥加密技术的速度快,可是公钥加密技术提供了更好的身份认证技术。ssl 的握手协议非常有效的让客户和服务器之间完成相互之间的身份认证,其主要过程如下: 客户端的浏览器向服务器传送客户端 ssl 协议的版本号,加密算法的种类,产生的随机数,以及其他服务器和客户端之间通讯所需要的各种信息。 服务器向客户端传送 ssl 协议的版本号,加密算法的种类,随机数以及其他相关信息,同时服务器还将向客户端传送自己的证书。 客户利用服务器传过来的信息验证服
6、务器的合法性,服务器的合法性包括:证书是否过期,发行服务器证书的 ca 是否可靠,发行者证书的公钥能否正确解开服务器证书的“发行者的数字签名”,服务器证书上的域名是否和服务器的实际域名相匹配。如果合法性验证没有通过,通讯将断开;如果合法性验证通过,将继续进行第四步。用户端随机产生一个用于后面通讯的“对称密码”,然后用服务器的公钥(服务器的公钥从步骤中的服务器的证书中获得)对其加密,然后将加密后的“预主密码”传给服务器。 如果服务器要求客户的身份认证(在握手过程中为可选),用户可以建立一个随机数然后对其进行数据签名,将这个含有签名的随机数和客户自己的证书以及加密过的“预主密码”一起传给服务器。
7、如果服务器要求客户的身份认证,服务器必须检验客户证书和签名随机数的合法性,具体的合法性验证过程包括:客户的证书使用日期是否有效,为客户提供证书的 ca 是否可靠,发行 ca 的公钥能否正确解开客户证书的发行 ca 的数字签名,检查客户的证书是否在证书废止列表(crl)中。检验如果没有通过,通讯立刻中断;如果验证通过,服务器将用自己的私钥解开加密的“预主密码”,然后执行一系列步骤来产生主通讯密码(客户端也将通过同样的方法产生相同的主通讯密码)。 服务器和客户端用相同的主密码即“通话密码”,一个对称密钥用于 ssl 协议的安全数据通讯的加解密通讯。同时在 ssl 通讯过程中还要完成数据通讯的完整性
8、,防止数据通讯中的任何变化。 客户端向服务器端发出信息,指明后面的数据通讯将使用的步骤中的主密码为对称密钥,同时通知服务器客户端的握手过程结束。 服务器向客户端发出信息,指明后面的数据通讯将使用的步骤中的主密码为对称密钥,同时通知客户端服务器端的握手过程结束。 ssl 的握手部分结束,ssl 安全通道的数据通讯开始,客户和服务器开始使用相同的对称密钥进行数据通讯,同时进行通讯完整性的检验。3 系统配置要求3.1 硬件要求3.2 软件要求操作系统:linuxhttp服务器:apache/1.3.33mod_ssl-2.8.22-1.3.33.tar.gzopenssl-0.9.7或以上4 安装流
9、程4.1 安装前准备下载以下软件包:apache_1.3.33.tar.gzmod_ssl-2.8.22-1.3.33.tar.gzopenssl-0.9.7f.tar.gz4.2 执行安装安装apache1. 拷贝以上三个文件到/usr/local,并解压tar zxvf apache_1.3.33.tar.gztar zxvf mod_ssl-2.8.22-1.3.33.tar.gztar zxvf openssl-0.9.7f.tar.gz2. 配置mod_sslcd mod_ssl-2.8.22-1.3.33./configure -with-apache=./apache_1.3.3
10、33. 设置ssl的基本路径cd ./apache_1.3.33ssl_base=./openssl-0.9.7f4. 配置apache./configure -prefix=/usr/local/apache -enable-module=ssl -enable-shared=ssl5. 编译/安装apache makemake install6. 编译openssl./config -prefix=/usr/local/opensslmakemake install4.3 安装后验证1. 检查目标目录是否已创建:/usr/local/apache/usr/local/openssl2. 检
11、查mod_ssl插件是否已生成/usr/local/apache/libexec/libssl.so3. 启动apache,检查是否可以访问cd /usr/local/apache/bin./apachectl startssl4.4 安装过程常见问题解决问题1名称5 系统配置5.1 调整黙认选项根据公司安全中心拟订的apache安全checklist.doc手册为参考,调整系统的黙认配置。5.2 虚拟机配置这里说的虚拟主机是指在一台机器上仅运行一个httpd后台程序 支持多个apache服务器,如在公司某部门有一台web服务器,名为 ,同时又想为另一个部门建立网站,网站内容也放在该机器上,通
12、过访问,这就要用到虚拟主机设置。设置apache虚拟主机通常有两种方案:u 基于ip的虚拟主机 这种方式需要在机器上设置ip别名,象上面的例子,在一台机器的网卡上绑定多个ip地址去服务多个虚拟主机。u 基于名字的虚拟主机它的优势就是不需要更多的ip地址,容易配置,不需要其它软硬件,现代的浏览器大多都支持这种方式。添加基于名字的虚拟主机步骤如下:1 修改httpd.conf,在最后添加以下配置# namevirtualhost 必须加在所有虚拟机配置之前namevirtualhost 80# 虚拟机一配置 serveradmin webmaster documentroot
13、 /usr/local/ oiweb_test_account/htdocs/ servername scriptalias /cgi-bin/ /usr/local/oiweb_test_account/cgi-bin/ errorlog logs/int_qq-error_log customlog logs/int_qq-access_log common serveradmin tipyluo documentroot /usr/local/oiweb_test_sales/htdocs/ servername scriptalias /cgi-bin/ /usr/local/oiwe
14、b_test_sales/cgi-bin/ errorlog logs/int_qq-error_log customlog logs/int_qq-access_log common5.3 单向认证https配置首先在配置之前明白一些基本概念,1. ssl所使用的证书可以是自建生成的,也可以通过一个商业性ca如verisign签署证书。2. 证书的概念:首先要有一个根证书(可自建),然后用根证书来签发服务器证书和客户证书,一般理解:服务器证书和客户证书是平级关系。在ssl必须安装根证书和服务器证书来认证。单向认证配置需要服务器公钥证书和证书对应的私钥,命名为server.crt和server
15、.key(可改为其它名字)。编辑httpd.conf,调整“”之间的内容:# general setup for the virtual hostdocumentroot /usr/local/oiweb_test_www/htdocsservername scriptalias /cgi-bin/ /usr/local/oiweb_test_www/cgi-bin/serveradmin rooterrorlog /usr/local/apache/logs/error_logtransferlog /usr/local/apache/logs/access_log# ssl engine
16、switch:# enable/disable ssl for this virtual host.sslengine on# ssl cipher suite:# list the ciphers that the client is permitted to negotiate.# see the mod_ssl documentation for a complete list.sslciphersuite all:!adh:!export56:rc4+rsa:+high:+medium:+low:+sslv2:+exp:+enull# server certificate:# poin
17、t sslcertificatefile at a pem encoded certificate. if# the certificate is encrypted, then you will be prompted for a# pass phrase. note that a kill -hup will prompt again. a test# certificate can be generated with make certificate under# built time. keep in mind that if youve both a rsa and a dsa# c
18、ertificate you can configure both in parallel (to also allow# the use of dsa ciphers, etc.)sslcertificatefile /usr/local/apache/conf/ssl.crt/server.crt#sslcertificatefile /usr/local/apache/conf/ssl.crt/server-dsa.crt# server private key:# if the key is not combined with the certificate, use this# di
19、rective to point at the key file. keep in mind that if# youve both a rsa and a dsa private key you can configure# both in parallel (to also allow the use of dsa ciphers, etc.)sslcertificatekeyfile /usr/local/apache/conf/ssl.key/server.key#sslcertificatekeyfile /usr/local/apache/conf/ssl.key/server-d
20、sa.key# server certificate chain:# point sslcertificatechainfile at a file containing the# concatenation of pem encoded ca certificates which form the# certificate chain for the server certificate. alternatively# the referenced file can be the same as sslcertificatefile# when the ca certificates are
21、 directly appended to the server# certificate for convinience.#sslcertificatechainfile /usr/local/apache/conf/ssl.crt/ca.crt# certificate authority (ca):# set the ca certificate verification path where to find ca# certificates for client authentication or alternatively one# huge file containing all
22、of them (file must be pem encoded)# note: inside sslcacertificatepath you need hash symlinks# to point to the certificate files. use the provided# makefile to update the hash symlinks after changes.#sslcacertificatepath /usr/local/apache/conf/ssl.crt#sslcacertificatefile /usr/local/apache/conf/ssl.c
23、rt/ca-bundle.crt# certificate revocation lists (crl):# set the ca revocation path where to find ca crls for client# authentication or alternatively one huge file containing all# of them (file must be pem encoded)# note: inside sslcarevocationpath you need hash symlinks# to point to the certificate f
24、iles. use the provided# makefile to update the hash symlinks after changes.#sslcarevocationpath /usr/local/apache/conf/ssl.crl#sslcarevocationfile /usr/local/apache/conf/ssl.crl/ca-bundle.crl# client authentication (type):# client certificate verification type and depth. types are# none, optional, r
25、equire and optional_no_ca. depth is a# number which specifies how deeply to verify the certificate# issuer chain before deciding the certificate is not valid.#sslverifyclient require#sslverifydepth 10# access control:# with sslrequire you can do per-directory access control based# on arbitrary compl
26、ex boolean expressions containing server# variable checks and other lookup directives. the syntax is a# mixture between c and perl. see the mod_ssl documentation# for more details.#sslrequire ( %ssl_cipher ! m/(exp|null)/ # and %ssl_client_s_dn_o eq snake oil, ltd. # and %ssl_client_s_dn_ou in staff
27、, ca, dev # and %time_wday = 1 and %time_wday = 8 and %time_hour = 20 ) # or %remote_addr = m/-9+$/# ssl engine options:# set various options for the ssl engine.# o fakebasicauth:# translate the client x.509 into a basic authorisation. this means that# the standard auth/dbmauth methods c
28、an be used for access control. the# user name is the one line version of the clients x.509 certificate.# note that no password is obtained from the user. every entry in the user# file needs this password: xxj31zmtzzkva.# o exportcertdata:# this exports two additional environment variables: ssl_clien
29、t_cert and# ssl_server_cert. these contain the pem-encoded certificates of the# server (always existing) and the client (only existing when client# authentication is used). this can be used to import the certificates# into cgi scripts.# o stdenvvars:# this exports the standard ssl/tls related ssl_*
30、environment variables.# per default this exportation is switched off for performance reasons,# because the extraction step is an expensive operation and is usually# useless for serving static content. so one usually enables the# exportation for cgi and ssi requests only.# o compatenvvars:# this expo
31、rts obsolete environment variables for backward compatibility# to apache-ssl 1.x, mod_ssl 2.0.x, sioux 1.0 and stronghold 2.x. use this# to provide compatibility to existing cgi scripts.# o strictrequire:# this denies access when sslrequiressl or sslrequire applied even# under a satisfy any situatio
32、n, i.e. when it applies access is denied# and no other module can change it.# o optrenegotiate:# this enables optimized ssl connection renegotiation handling when ssl# directives are used in per-directory context. #ssloptions +fakebasicauth +exportcertdata +compatenvvars +strictrequire ssloptions +s
33、tdenvvars ssloptions +stdenvvars# ssl protocol adjustments:# the safe and default but still ssl/tls standard compliant shutdown# approach is that mod_ssl sends the close notify alert but doesnt wait for# the close notify alert from client. when you need a different shutdown# approach you can use one
34、 of the following variables:# o ssl-unclean-shutdown:# this forces an unclean shutdown when the connection is closed, i.e. no# ssl close notify alert is send or allowed to received. this violates# the ssl/tls standard but is needed for some brain-dead browsers. use# this when you receive i/o errors
35、because of the standard approach where# mod_ssl sends the close notify alert.# o ssl-accurate-shutdown:# this forces an accurate shutdown when the connection is closed, i.e. a# ssl close notify alert is send and mod_ssl waits for the close notify# alert of the client. this is 100% ssl/tls standard c
36、ompliant, but in# practice often causes hanging connections with brain-dead browsers. use# this only for browsers where you know that their ssl implementation# works correctly. # notice: most problems of broken clients are also related to the http# keep-alive facility, so you usually additionally wa
37、nt to disable# keep-alive for those clients, too. use variable nokeepalive for this.# similarly, one has to force some clients to use http/1.0 to workaround# their broken http/1.1 implementation. use variables downgrade-1.0 and# force-response-1.0 for this.setenvif user-agent .*msie.* nokeepalive ss
38、l-unclean-shutdown downgrade-1.0 force-response-1.0# per-server logging:# the home of a custom ssl log file. use this when you want a# compact non-error ssl logfile on a virtual host basis.customlog /usr/local/apache/logs/ssl_request_log %t %h %ssl_protocolx %ssl_cipherx %r %b/virtualhost对于单向认证的模式,从
39、开发上来说与不使用https没有不同,不需要特殊处理。5.4 双向认证https配置在此环境中,至少必须有三个证书:即根证书(ca.crt),服务器证书,客户端证书。在生成证书之前,一般会有一个私钥,同时用私钥生成证书请求,再利用证书服务器的根证来签发证书。编辑httpd.conf,在上述的配置基础上作进一步改动,添加以下几项配置(取消注释):sslcacertificatefile /usr/local/apache/conf/ssl.crt/ca.crtsslverifyclient require# 因为一个ca证书能够被另一个ca证书验证,所以可以形成一个ca证书链.# 使用该指令可指
40、定服务器验证用户证书时可以查找多少个ca证明.sslverifydepth 10我们通常所指的双向认证是指的协议级的认证,由浏览器和web服务器自动完成。然而对于带证书访问我们网站的所有用户来讲,如果不作应用级的认证,发挥不出双向认证的特点。我们所指的应用级认证就是在业务处理的逻辑上加入对用户证书的认证,我们知道每个证书都有一个common name字段,这个字段通常保存用户的特有信息(比如姓名、域名等),通常要求二张不同的证书这个字段是不能相同的,那么我们就可以利用这个字段来作用户的认证。完成协议认证后,在web服务器的当前会话中会多出一些环境变量,其中包含用户证书的相关信息,比如证书序列号
41、(ssl_client_m_serial)、公用名(ssl_client_s_dn_cn)等,利用这些信息和用户的登录信息的接口可以达到提升安全级别的功能。5.5 自建根证书安装openssl后,在openssl下有一个ca.sh文件,就是利用此文件来签证,来签三张证书,然后利用这三张证书来布ssl服务器。操作步骤如下:1. 创建工作目录,比如创建/home/tipyluo/crt(可自定义)。2. 将ca.sh文件copy至/home/tipyluo/crt目录cp /usr/local/openssl/ssl/misc/ca.sh /home/tipyluo/crt/3. 自建根证书和私钥
42、./ca.sh -newca运行ca.sh -newca,他会找你要ca需要的一个ca自己的私有密钥密码文件。如果没有这个文件?按回车会自动创建,输入密码来保护这个密码文件。之后会要你的一个公司信息来做ca.crt文件。最后在当前目录下多了一个./democa这样的目录./democa/private/cakey.pem就是ca的key文件啦,./democa/cacert.pem就是ca的crt文件了。country name (2 letter code) au:cnstate or province name (full name) some-state:guangdonglocality name (eg, city) :shenzhenorganization name (eg, company) internet widgits pty ltd:tencentorganizational unit name (eg, section) :osscommon name (eg, your name) :cftemail address :tipyl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 幼儿园2025秋季活动评估计划
- 2025工厂职工安全培训考试试题含答案(满分必刷)
- 25年公司三级安全培训考试试题附答案【典型题】
- 2025四年级班主任心理健康教育计划
- 2024-2025安全标准化安全培训考试试题突破训练
- 2025年度城市交通改善工作计划范文
- 幼儿园秋季饮食卫生管理计划
- 2025年高校学生个人成长学习计划范文
- 2024浙江宁波水产品批发市场有限公司招聘1人笔试参考题库附带答案详解
- 三年级下册班主任科技教育计划
- 足球裁判规则PPT
- 利润分配专项审计
- 探索性数据分析简介课件
- Q∕SY 01186-2020 地震资料构造解释技术规范
- 刨花板生产线
- PPT肾癌诊疗指南CSCO课件
- 螺纹的标注-PPT课件
- 《港口装卸工艺》课件chap3 件杂货
- 原材料进厂检验管理制度及检验规程
- 建设单位业主方工程项目管理流程图
- 碎石挤密桩复合地基施工工法解读
评论
0/150
提交评论