2010年4月 Archives
resin的配置文件类似xml,语法规范也遵循xml的写法,今天遇到了特殊字符的问题,数据库密码包含了特殊字符。
<init-param driver-name="oracle.jdbc.driver.OracleDriver"/>
<init-param url="jdbc:oracle:thin:@localhost:1521:Test"/>
<init-param user="username"/>
<init-param password="123&(45aq"/>
...
</resource-ref>
#sh start_server.sh
Starting Resin on Thu, 22 Apr 2010 18:39:48 +0800 (CST)
com.caucho.xml.XmlParseException: /home/resin/conf/resin.conf:8: malformed entity ref at `('
at com.caucho.xml.XmlParser.error(XmlParser.java:2769)
at com.caucho.xml.XmlParser.parseCharacterReference(XmlParser.java:1002)
at com.caucho.xml.XmlParser.parseValue(XmlParser.java:1192)
at com.caucho.xml.XmlParser.parseAttributes(XmlParser.java:702)
at com.caucho.xml.XmlParser.parseElement(XmlParser.java:603)
at com.caucho.xml.XmlParser.parseNode(XmlParser.java:377)
at com.caucho.xml.XmlParser.parseInt(XmlParser.java:248)
at com.caucho.xml.AbstractParser.parse(AbstractParser.java:645)
at com.caucho.util.Registry.parse(Registry.java:199)
at com.caucho.util.Registry.parse(Registry.java:174)
at com.caucho.server.http.ResinServer.init(ResinServer.java:311)
at com.caucho.server.http.ResinServer.main(ResinServer.java:1176)
其原因并不是“(”引起的,罪魁祸首是“&”
解决办法是使用&替换&
如:
<init-param password="123&(45aq"/>
xml文件中其他的几个特殊字符做同样处理即可:
* & = & (ampersand)
* < = < (left angle bracket, less-than sign)
* > = > (right angle bracket, greater-than sign)
* " = " (quotation mark)
* ' = ' (apostrophe)
cnnic使用了自己的根证书CNNIC ROOT和中级根证书CNNIC SSL,(好多人都在抵制cnnic root哦!,不过既然boss同意使用CNNIC证书,那俺也只能照办了~)
3月1日以后替换的证书都需要替换之前Entrust授权的ROOT。
但是一些主、客观上的原因导致并不是所有的浏览器或者客户端都认为cnnic的根证书是合法可信的,比如firefox3.0。还有java客户端,如我的实际情况是在配置完毕后使用浏览器访问https没有问题,但是使用java的HttpURLConnection调用时,web端有以下错误日志:
[Wed Apr 7 15:25:10 2010] [error] mod_ssl: SSL handshake failed (server 2hei.net:443, client 218.241.111.117) (OpenSSL library error follows)
[Wed Apr 7 15:25:10 2010] [error] OpenSSL: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown
看结果貌似java不识别cnnic为truststore。
经过与cnnic的support沟通后,得到了解决方案,总结如下:
1、use keytool to export the server certificate from the certs keystore.
#keytool -export -keystore certs -alias jamie -file server.cer
也可以使用IE浏览器导出base64的server.cer文件。
2、Use keytool to create a new keystore named jssecacerts (which will be used as a truststore by SecureBrowser). Import server.cer into jssecacerts.
#keytool -import -keystore jssecacerts -alias jamie -file server.cer
3、Finally, copy jssecacerts to the lib/security subdirectory of your java.home directory. (On your client machine.)
Now SecureBrowser will use jssecacerts as a truststore to authenticate SecureServer.
4、edit java code,add this:
// Register JSSE
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()) ;
// Simply set the protocol handler property to use SSL.
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
参考文档
http://onjava.com/pub/a/onjava/2001/05/03/java_security.html?page=4




