windows 2003 server下安装svn+apache+ssl

来源:互联网 发布:淘宝交纳保证金在哪里 编辑:程序博客网 时间:2024/06/01 13:11

来自http://hi.baidu.com/patrolsun/blog/item/251659c2f40e1e32e5dd3bde.html

 windows 2003 server下安装svn+apache+ssl(二)


1.因为前篇使用的apache没有带ssl,所以你可以自己下载ssl模块,然后将mod_ssl.so拷到Apache的modules目录、openssl.exe、libeay32.dll、ssleay32.dll拷到bin目录、conf/ssl.conf拷到conf目录。当然您也可以直接下载apache_2.2.11-win32-x86-openssl-0.9.8i.msi

2.在Apache的conf目录中用文本编辑器打开ssl.conf,如果没有%apache%/conf/ssl.conf文件,请把%apache%/conf/extra/httpd-ssl.conf拷贝到%apache%/conf下。
2.1将下面这些行用#注释掉: 
DocumentRoot "c:/apache/htdocs"
ServerName www.example.com:443
ServerAdmin you@example.com
ErrorLog logs/error_log
TransferLog logs/access_log
2.2修改
SSLCertificateFile conf/ssl.crt/server.crt

SSLCertificateFile conf/ssl/my-server.cert
2.3修改
SSLCertificateKeyFile conf/ssl.key/server.key

SSLCertificateKeyFile conf/ssl/my-server.key
2.4修改
SSLMutex file:logs/ssl_mutex

SSLMutex default
2.5删除以下两行(如果有):
<IfDefine SSL>
</IfDefine>
2.6打开Apache配置文件(httpd.conf),去掉这行的注释
#LoadModule ssl_module modules/mod_ssl.so
2.7在httd.conf中找到
# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
在其下方添加
Include conf/ssl.conf    
这样就可以把ssl.conf包含在内啦(也可以是httpd-ssl.conf)

3.Openssl需要一个配置文件。你可以从这里下载一个可工作的版本http://tud.at/programm/openssl.cnf 将它保存到%apache%/bin/openssl.cnf。(如果安装带ssl的apache的话,apache目录下就有该文件openssl.cnf,注意一定放到%apache%/bin/下)

4.创建一个SSL证书。你可以打开一个命令行窗口,然后cd到%apache%/bin/
4.1敲入命令
openssl req -config openssl.cnf -new -out my-server.csr
如果第3步不能确保正确,此时就会报下列错误:
WARNING: can't open config file: /usr/local/ssl/openssl.cnf
error on line -1 of bin/openssl.cnf
2380:error:02001003:system library:fopen:No such process:./crypto/bio/bss_file.c
:126:fopen('bin/openssl.cnf','rb')
2380:error:2006D080:BIO routines:BIO_new_file:no such file:./crypto/bio/bss_file
.c:129:
2380:error:0E078072:configuration file routines:DEF_LOAD:no such file:./crypto/c
onf/conf_def.c:197:
注意后面会让你输入,只需要在PEM输入2段相同的句子,然后在国家、省和公司后面输入,其他[]为空的就不要输入啦
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
.............++++++
.....................................................++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
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]:ah
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:company
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

4.2敲入命令
set OPENSSL_CONF=openssl.cnf
4.3敲入命令
openssl rsa -in privkey.pem -out my-server.key
如果不输入4.2的命令,那么此时会出现下面的错误:
WARNING: can't open config file: /usr/local/ssl/openssl.cnf
Enter pass phrase for privkey.pem:
unable to load Private Key
2328:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:./
crypto/evp/evp_enc.c:466:
2328:error:0906A065:PEM routines:PEM_do_header:bad decrypt:./crypto/pem/pem_lib.
c:425:
注意该命令还会让你输入PEM,注意和上面的PEM保持一致
Enter pass phrase for privkey.pem:
writing RSA key
4.4敲入命令
openssl x509 -in my-server.csr -out my-server.cert -req -signkey my-server.key -days 4000
创建一个4000天后才过期的证书
Loading 'screen' into random state - done
Signature ok
subject=/C=cn/ST=ah/O=company
Getting Private key
4.5敲入命令
openssl x509 -in my-server.cert -out my-server.der.crt -outform DER
4.6最后一步,把这些命令在Apache目录下创建了一些文件(my-server.der.crt, my-server.csr, my-server.key, .rnd, privkey.pem, my-server.cert)。将这些文件拷贝到目录conf/ssl

5. 重启Apache服务即可使用ssl啦,访问方式是:https://servername/

    servername为httpd.conf中ServerName项的值。如果没有域名可以是IP地址。

6.强制通过SSL来访问

当你配置了SSL来提高版本库安全时,你可能想禁用无SSL的http访问方式,而只允许通过https访问。要达到这种效果,你要在<Location>块加入另外一个指示器SSLRequireSSL。
一个示例<Location>块可能像这样:
<Location /svn>
DAV svn
SVNParentPath D:/svn 
AuthType Basic 
AuthName "Subversion repositories" 
AuthUserFile D:/SVN/passwd 
#AuthzSVNAccessFile D:/SVN/svnaccessfile 
Require valid-user 
SSLRequireSSL
</Location>

 

7.问题

   1)无法使用80端口

         原因:IIS本身占用了80端口,需要把IIS禁止。

         方法 :控制面板-->管理工具-->服务-->IIS-->禁止

    2)步骤4会生成一个证书,需要导入IE,导入方法:

       IE--> 工具-->internet选项-->内容-->证书-->导入-->下一步-->浏览-->导入生成的证书。

 

原创粉丝点击