# CockRoachDB ORM 测试 CockRoachDB 中文文档地址:http://doc.cockroachchina.baidu.com/ ## 生成安全证书 http://doc.cockroachchina.baidu.com/#quick-start/start-a-local-cluster/from-binary/ ``` # Create a certs directory and safe directory for the CA key. # If using the default certificate directory (`${HOME}/.cockroach-certs`), make sure it is empty. mkdir certs mkdir my-safe-directory # Create the CA key pair: cockroach cert create-ca --certs-dir=certs --ca-key=my-safe-directory/ca.key # Create a client key pair for the root user: cockroach cert create-client root --certs-dir=certs --ca-key=my-safe-directory/ca.key # Create a key pair for the nodes: cockroach cert create-node localhost $(hostname) --certs-dir=certs --ca-key=my-safe-directory/ca.key ``` ## 启动数据库 ``` # 非安全模式 cockroach start --insecure --host=localhost # 安全模式: cockroach start --certs-dir=certs --host=localhost --http-host=localhost ``` ## 命令行操作内置客户端 连接: ``` # 非安全模式 cockroach sql --insecure # 安全模式: cockroach sql --certs-dir=certs ``` 退出: ``` \q ``` ## 使用OpenSSL生成证书 C#使用的pkcs12证书: ``` openssl pkcs12 -export -password pass: -in client.root.crt -inkey client.root.key -out client.root.pk12 ``` Java使用的pkcs8证书: ``` openssl pkcs8 -topk8 -inform PEM -outform DER -in client.root.key -out client.root.pk8 -nocrypt ```