Archive

Author Archive

Fedora12 下配置 SVN 服务器

April 9th, 2010 lennydou No comments

assume the following dummy IP addresses and port of the server for the rest of the article: (replace these with your own IP, and port values)

  external IP: 55.444.444.55
  internal lan IP: 192.168.1.200
  svn port: 8080

Most of the operations here will require that you have access to the root account, as always.

I like to use the yum extender and an http gui to manipulate apache’s settings, so those need to be installed:

  > yum -y install yumex

This installs a gui for yum, which can be found, after a successful install on the desktop at:

  Applications > Yum Extender

Using the yum extender, we can see what has already been installed or not, on the linux machine. So, we should make sure that the Apache server is installed, and also install the Apache configuration tool (the http gui):

  httpd
  system-config-httpd

We also need to install the Apache server module for the subversion server:

  mod_dav_svn

Next, to install SVN subversion we can go back to the command line, and install it using yum:

  > yum install subversion

With these installations complete we can begin to create the necessary directories and modifying the various configuration files.

As root, create the following directory:

  > mkdir -p /var/www/svn/repository

change to that directory,

  > cd /var/www/svn/repository

and create a test repository,

  > svnadmin create test_svn

Notice: use svnadmin command maybe get an error: SQLite编译为3.6.20,但是运行于3.6.17。然后会发现repository目录下面并没有生成任何东西。此时需要在Yum Extender里面找到两个sqlite开头的包,然后升级这两个包就可以了。

Actually, these SVN directories can be placed anywhere, as long as you keep track of the correct path for the modifications that will need to be added later to the configuration files.

Next, change directory, and set the ownership so that Apache can access the SVN directories.

  > cd /var/www
  > chown -R apache.apache svn

Next, we modify Apache’s settings.

Before modifying Apache’s settings it would be a good idea to make a backup of the configuration file, in case the Apache server won’t restart, we can always restore the configuration file and try again.

  > cd   /etc/httpd/conf.d
  > cp  system-config-httpd.conf   system-config-httpd.conf.backup

Start the httpd configuration gui:

  > /usr/bin/system-config-httpd &

In this window set the server name to:
  192.168.1.200
Add to Available Addresses :

  listen to all addresses
  port: 8080

Then to save these settings, hit OK. These changes will modify the file:

  /etc/httpd/conf.d/system-config-httpd.conf

Restart the Apache server. There are operating system line commands for restarting the http daemon, but a GUI is just as easy, and we can keep the GUI open since we will need to restart Apache a few more times.

  /usr/bin/system-config-services &

Scroll down, select the daemon labeled httpd, and hit restart. Hopefully Apache restarts successfully, if not, then you may need to reload the original configuration file and try again.

Next, we will need to modify subversion’s configuration files.

To modify subversion’s configuration files we need to edit the following:

  /etc/httpd/conf.d/subversion.conf

This file was created with the installation of subversion.

The first two lines of the file should contain:

  LoadModule dav_svn_module modules/mod_dav_svn.so
  LoadModule authz_svn_module modules/mod_authz_svn.so

… if not, then those modules need to be installed.

First create a backup of the configuration file:

  > cp subversion.conf subversion.conf.backup

Modify the Location section of the file to the following:

  n  

Notice here how the directory for the repository we created earlier using the svnadmin command is not listed above. The above settings only point to the root location of the repository, or rather its parent path.

Save these settings, and restart the Apache server.

At this point we can test the SVN server from another PC on the private LAN. We can use our favorite web browser on a windows, linux, or mac PC, and enter the following URL:

  http://192.168.1.200:8080/svn/test_svn/

We should get a response page that looks like the following:

  Revision 0: /

  ————————————————————–
  Powered by Subversion version 1.4.4 (r25188).

If you can see this, then the SVN server is running.
Next, we need to add some password protection.

Here we add some password protection to the new SVN server.
For this, lets assume a username of trill, and a password of towel42.
Make the password directory:

  > mkdir /etc/httpd/passwd

To create the initial password file, and add a user called “trill”:

  > htpasswd -c /etc/httpd/passwd/svnpasswords trill

When the program asks, enter the password:

  towel42

Other command line options to htpasswd will allow you to add or delete more users.

For example, to add another user, called “asmith”:

  > htpasswd /etc/httpd/passwd/svnpasswords asmith

When the program asks, enter the password:

  neo22

This will append the user “asmith” to the passwords file, with the above password.

Edit the subversion configuration file to turn on the SVN authorization. We found that commenting out the <LimitExcept lines allowed the SVN password authorization to work. So the final subversion configuration file:

 /etc/httpd/conf.d/subversion.conf

… can look like this:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn/repository
</Location>

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn/repository

   # Limit write permission to list of valid users.
   #<LimitExcept GET PROPFIND OPTIONS REPORT>
      # Require SSL connection for password protection.
      # SSLRequireSSL

      AuthType Basic
      AuthName “Authorization Realm”
      AuthUserFile /etc/httpd/passwd/svnpasswords
      Require valid-user
   #</LimitExcept>
</Location>

After having made these changes, restart the Apache server as above. Now, if we go back to the PC with the web browser, we can test the password authentication. Restart the web browser and enter into the URL:

  http://192.168.1.200:8080/svn/test_svn/

We should see a window pop up, prompting for a user’s name and a corresponding password.

Enter trill for the user name, and towel42 for the password. This should let us see the svn server’s response page as before.

Categories: English - 英文 Tags: ,

Tomcat 下配置 HTTPS 数字证书

March 20th, 2010 lennydou No comments

在Tomcat下配置HTTPS的证书, 用户第一次访问需要下载安装证书,然后以后访问就可以以安全连接的方式访问了.配置过程首先需要使用JDK自带的keytool来生成一个keystore文件,然后从keystore文件导出一个certreq文件,然后使用该文件到www.freeca.cn 生成一个证书文件,再把该证书文件导入JVM就OK了.

具体配置过程如下:

( 我的参数如下: IP地址192.168.2.101,用户名是lenny,密码是123456,组织都是buaa,城市是Beijing,使用的操作系统是win7 )

1. 打开 cmd ,生成keystore文件lenny

keytool -genkey -alias lenny -keyalg RSA  -keystore C:\lenny -validity 36500 -keysize 512

其中lenny是别名,可以随便取;-keyalg RSA是加密算法;-keystore C:\lenny 是生成的文件(在C盘下);       -validity 36500是有效期为10年;-keysize 512生成的密钥是512位的。

( 注意: 填写具体信息时,”名字和姓氏”一定是你的域名或IP地址,比如我在实验室没有域名,IP地址为192.168.2.101,所以我的”名字和姓氏”填写的是192.168.2.101,所以实验室的其他电脑也可以使用https访问我的Web应用程序  )

 

2. 使用 keytool -certreq 命令生成certreq文件 C:\serverreq

keytool -certreq -keystore c:\lenny -alias lenny -file c:\serverreq  

3. 从C:\lenny.文件中生成了CSR文件C:\serverreq文件, 然后使用notepad++打开c:\serverreq文件。把里面的内容复制出来,我的文件serverreq内容大概是

—–BEGIN NEW CERTIFICATE REQUEST—–
MIIBITCBzAIBADBnMQswCQYDVQQGEwJjbjEQMA4GA1UECBMHQmVpamluZzEQMA4GA1UEBxMHQmVp
amluZzEPMA0GA1UEChMGYmVlbHVuMQ8wDQYDVQQLEwZiZWVsdW4xEjAQBgNVBAMTCWxvY2FsaG9z
dDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCYIMDa/LxbGBbdL3jEa8zMzBMKQdtNVib0rO4rVz4J
FiDfZzpsMRPaCCNR7dMN92da/hnnhrYbMQTknrMlj6dxAgMBAAGgADANBgkqhkiG9w0BAQUFAANB
AGUFd9d9FHNH6oFLMmL6s5RBW7tVa4v8j4pS5vQNGE/4DFbRv+MyyVyZvNcetlNaLjuFcyoN7PB8
N9L33Y/D9to=
—–END NEW CERTIFICATE REQUEST—–

然后打开 http://www.freeca.cn 网站,然后在申请证书Tab里面选择 CSR 申请方式,把上述内容粘贴到文本框中,然后验证 CSR,网站会让你选择一个邮箱,然后会把内容发到你邮箱里。第一封邮件是让你确认你要申请数字证书,确认后会收到第二封邮件,把里面的内容拷贝到记事本,然后保存并把后缀名改成 .cer。我取得名字是lenny.cer。

 

4. 把之前生成的C:\lenny 中的密码信息导入到 C:\lenny.cer文件中

keytool -export -keystore c:\lenny -alias lenny -file C:\lenny.cer

 

5. 把从邮箱中拷贝出的文字生成的C:\lenny.cer文件导入到JVM。导入的方法如下:

cd C:\Program Files\Java\jdk1.7.0\jre\lib\

keytool -import -keystore .\security\cacerts -alias lenny -file c:\lenny.cer

 ( 切记: 这一步需要输入密码,这个密码是 changeit,之前的密码都是创建keystore时的密码123456 )

 

6. 然后设置Tomcat根目录下面的/conf/server.xml,然后修改为

<Connector protocol=”org.apache.coyote.http11.Http11Protocol”
           port=”8443″ minSpareThreads=”5″ maxSpareThreads=”75″
           enableLookups=”true” disableUploadTimeout=”true”
           acceptCount=”100″  maxThreads=”200″
           scheme=”https” secure=”true” SSLEnabled=”true”
           keystoreFile=”C:\lenny” keystorePass=”123456″
           clientAuth=”false” sslProtocol=”TLS”/>

 

7. 然后在网页里输入https://192.168.2.101:8080/ 就可以访问了。第一次访问的时候,还会弹出Certificate Error页面。这是可以安装证书,然后以后访问就可以使用安全连接的方式了。

 ( 注意: 浏览器访问https时,第一次需要安装证书,记得把证书安装到Trusted Root(根)位置 )

 

Categories: Chinese - 中文 Tags: , ,

Tomcat6下配置HTTPS

February 27th, 2010 lennydou No comments

我使用的JDK版本为JDK7,使用的的Tomcat版本为6.0.24;配置Tomcat下的HTTPS其实很简单,只需要完成两步工作就可以了;操作系统为Windows 7。

一、生成“服务器证书文件”

我把生成的“服务器证书文件”取名为tomcat.key(也可以取成abc.keystore,随自己喜欢就好)。简单起见,我把tomcat.key放在C盘根目录下面(我的配置环境为windows,linux类似)。
首先使用JDK自带的工具keytool生成一个“服务器证书”,取名为tomcat.key。

C:\Users\Administrator>keytool -genkey -alias tomcat -keyalg RSA -keystore C:\to
mcat.key
输入keystore密码:
再次输入新密码:
您的名字与姓氏是什么?
[Unknown]:  beelun
您的组织单位名称是什么?
[Unknown]:  beelun
您的组织名称是什么?
[Unknown]:  beelun
您所在的城市或区域名称是什么?
[Unknown]:  beijing
您所在的州或省份名称是什么?
[Unknown]:  beijing
该单位的两字母国家代码是什么
[Unknown]:  cn
CN=beelun, OU=beelun, O=beelun, L=beijing, ST=beijing, C=cn 正确吗?
[否]:  y

输入<tomcat>的主密码
(如果和 keystore 密码相同,按回车):

C:\Users\Administrator>jdk -version
‘jdk’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Administrator>java -version
java version “1.7.0-ea”
Java(TM) SE Runtime Environment (build 1.7.0-ea-b23)
Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode, sharing)

C:\Users\Administrator>

按照提示,输入密码。我输入的密码为123456(注意:此密码在配置server.xml时需要)。其他信息按照提示输入就可以,在输入tomcat主密码时,我直接键入回车,使其和keystore的密码保持一致。

此时,在C盘下面就生成了一个PCKS1.2格式的数字证书文件C:\tomcat.key。

二、配置server.xml文件

修改tomcat\conf目录下面的server.xml文件,添加一项:

<Connector protocol=”org.apache.coyote.http11.Http11Protocol”
port=”8443″ minSpareThreads=”5″ maxSpareThreads=”75″
enableLookups=”true” disableUploadTimeout=”true”
acceptCount=”100″  maxThreads=”200″
scheme=”https” secure=”true” SSLEnabled=”true”
keystoreFile=”C:\tomcat.key” keystorePass=”123456″
clientAuth=”false” sslProtocol=”TLS”/>

需要注意一行“keystoreFile=”C:\tomcat.key” keystorePass=”123456″”,其中keystorefile是你生成的“服务器证书文件”,keystorePass是该服务证书文件的密码。

三、在浏览器地址栏里输入 https://localhost:8443/ 检验一下就OK了。

Update
From http://forums.java.net/jive/message.jspa?messageID=282519

I found some hints on the web that
CN should be the fully-qualified domain name of your server host

I replaced “localhost” with “pc_name”.”domain_name”
and it worked. They (pc_name and domain_name) are concatenated by dot.

Note:
My “domain_name” contains dots too.

I tested certificates on the same PC, but maybe this help you.

Categories: Chinese - 中文 Tags: , ,