使用openssl申请apple 开发证书

首选需要生成privkey在生成csr文件用于上传到apple

openssl genrsa -out privkey.key 2048

生成 csr

openssl req -new -key privkey.key -out privkey.csr

将apple开发者中心得到的cer文件转换为p12

首先需要装cer转换为pem

openssl x509 -in ios_distribution.cer -inform DER -out ios_distribution.cer.pem -outform PEM

然后在转换为p12,过程需要一个密码,在导入的时候使用

openssl pkcs12 -export -inkey privkey.key -in ios_distribution.cer.pem -out ios_distribution.p12

mysql innodb myisam 表格式互转

innodb 转换为 myisam

SELECT  CONCAT('ALTER TABLE ', table_name, ' ENGINE=MyISAM;') AS sql_statements  INTO OUTFILE '/tmp/result.txt'
FROM    information_schema.tables AS tb
WHERE   table_schema = 'TableName'
AND     `ENGINE` = 'InnoDB'
AND     `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

source /tmp/result.txt;

myisam 转换为 innodb

SELECT  CONCAT('ALTER TABLE ', table_name, ' ENGINE=InnoDB;') AS sql_statements  INTO OUTFILE '/tmp/result.txt'
FROM    information_schema.tables AS tb
WHERE   table_schema = 'TableName'
AND     `ENGINE` = 'MyISAM'
AND     `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

source /tmp/result.txt;

基于 Quercus 的手游项目终于上线了

经过半年的开发,我们第一款手游戏终于开发完毕,架构使用了 netty + Quercus 实现用 php 通过 websocket 与客户端通信。

项目上线近一个月,基本稳定。而且不存在性能方面问题,之前在内网测试,pc 机 4G 内存,在线 1000 人,没有卡动感觉。 这个数

字足以满足我们的需求, 想用 Quercus 大胆的用吧,到 4.0.39 应该会更完美,希望支持 Quercus 的多起来,与 hhvm 的火爆程度

真是是没法比。

debian openvz vps 优化

比较喜欢 debian vps ,系统比较简洁,而且很省内存,但大部分的 vps 商都使用的标准模版,带了不少垃圾东西。

首先进行系统更新

apt-get update && apt-get upgrade

安装sysv-rc-conf做为开机管理项

apt-get install sysv-rc-conf

先删除 apache 相关,使用 nginx 代替

apt-get remove --purge apache*

删除sendmail 相关

apt-get remove --purge sendmail* sasl2-bin

删除bind9相关

apt-get remove --purge bind9-*

删除xinetd 相关

apt-get remove --purge xinetd 

删除samba相关

apt-get remove --purge samba-*

删除rpcbind相关

apt-get remove --purge rpcbind

debain OpenVZ 删除 apache

debain 系统的 vps ,如 directspace 一般初始都安装了 apache 而我要用 nginx ,但直接用 aptitude 删除,竟然删不掉

aptitude remove apache2

在次使用 aptitude

aptitude remove apache2-doc apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common

还是没删掉,始用 dpkg

dpkg --purge apache2-doc apache2.2-common

终于清附掉了..

blog 搬出 phpcloud

刚开始 phpcloud 推的时候,由于是zend推出的,想去试用一下,就把blog迁了过去,没想到麻从此开始了。

blog 访问并不大,但是 phpcloud 经常 把我的服务挂起,估计可能是用的人比较大,资源比较吃紧吧,稍占点资源就给挂起,

刚好 bae3.0 推出,比较中意,适用中。

java(android) rsa 实现与 php 服务端通信

rsa 密钥生成 见 http://blog.andsky.com/js-rsa-use-openssl-make-public-pirvate-key/

android 客户端用rsa 公钥加密后经 base64 编码发到 服务端,服务端使用私钥解密

客户端代码

import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.spec.RSAPublicKeySpec;
import javax.crypto.Cipher;
import sun.misc.BASE64Encoder;



public class rsa {


	public static void main(String[] args) throws Exception {

		String modulus = "C34FF1FF9771ED88814C26905297BAEDCEC03B847D8AB5620848FC100AC0564FAD5364E9834E29118E7B5F8B1B9EAB201730C4860E8AF2ED2E028704105A01044501A9EF6DA2968E76273AAE496A0963A2FEA9B6179A86F28ACC61C087FB1AEEA4E1CB0ADBB9B757C303741DE602FD790953C8E2C004A425C7CAF4813F403DCD";
        String publicExponent = "010001";

        rsa key = new rsa();
        PublicKey publicKey = key.getPublicKey(modulus, publicExponent);
        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");


        //明文
        String tString = "aabbsdfsdf";
        byte[] plainText = tString.getBytes("UTF-8");
        //加密
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        byte[] enBytes = cipher.doFinal(plainText);
        System.out.println(new BASE64Encoder().encode( enBytes ));
	}


	 public PublicKey getPublicKey(String modulus,String publicExponent) throws Exception {
         BigInteger m = new BigInteger(modulus, 16);
         BigInteger e = new BigInteger(publicExponent, 16);
         RSAPublicKeySpec keySpec = new RSAPublicKeySpec(m,e);
         KeyFactory keyFactory = KeyFactory.getInstance("RSA");
         PublicKey publicKey = keyFactory.generatePublic(keySpec);
         return publicKey;

   }




}

服务端代码

 function privatekey_decodeing($crypttext, $privatekey)
    {

        $prikeyid = openssl_get_privatekey($privatekey);
        if (openssl_private_decrypt($crypttext, $sourcestr, $prikeyid,OPENSSL_PKCS1_PADDING))
        {
            return $sourcestr;
        }
        return FALSE;
    }

 $i = file_get_contents("private.key");

$base = 'fgvroFPT8GCIPYkGZJ834V0zQsnwbHKsCpFjpdN6TowUuxc6Bxu5PCF7SaZvb+3eCVEsuAjN73IP
QhRclqPiSv0MNPeZaYxNVPCDBkalsW3+/OuwPr7sQ53/rDwr2et0FnKJtkNyaFROMnxI9wRyg2Tx
h4+Fe60ypCvwY+wT8eg=';

	$b = base64_decode($base);
var_dump(privatekey_decodeing($b, $i));

quercus 4.0.38 发布

修正了不少bug 真是越来越完善了,赞一个

quercus: empty() needs to call ArrayAccess->offsetExists() (#5612, rep by G. Krall)
quercus: session_status() not implemented (#5609, rep by G. Krall)
quercus: self doesn’t work inside a namespace (#5608, G. Krall)
quercus: ReflectionParameter->getClass() not implemented (#5607, rep by G. Krall)
quercus: IllegalArgumentException vfs: not found on JBoss (#5606, rep by G. Krall)
quercus: ReflectionFunction does not work for closures (#5605, rep by G. Krall)
quercus: Xml reader is not working (#5603, rep by qumo)
quercus: call_user_func() needs to call __invoke (#5601, rep by G. Krall)
quercus: instanceof Closure returns false for closures (#5600, rep by G. Krall)
quercus: QuercusCompiledScript.eval() needs to return the Value object (#5589, rep by S. Guo)
quercus: ScriptEngineManager.getEngineByName(“php”) returns Quercus with unicode.semantics=off (#5588, rep by S. Guo)