[英]PostgreSQL server not able to start
我正在为我的应用程序使用PostgreSQL服务器。 我正在尝试使用SSL证书实现安全连接。 我在postgresql.conf中将ssl属性修改为“ on”。 我生成使用以下Java代码加密的自签名证书和密钥,它使用pbe加密私钥。
byte[] encodedprivkey = privKey.getEncoded();
String MYPBEALG = "PBEWithSHA1AndDESede";
String password = "test123";
int count = 20;// hash iteration count
Random random = new Random();
byte[] salt = new byte[8];
random.nextBytes(salt);
PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count);
PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray());
SecretKeyFactory keyFac = SecretKeyFactory.getInstance(MYPBEALG);
SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
Cipher pbeCipher = Cipher.getInstance(MYPBEALG);
// Initialize PBE Cipher with key and parameters
pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
// Encrypt the encoded Private Key with the PBE key
byte[] ciphertext = pbeCipher.doFinal(encodedprivkey);
// Now construct PKCS #8 EncryptedPrivateKeyInfo object
AlgorithmParameters algparms = AlgorithmParameters.getInstance(MYPBEALG);
algparms.init(pbeParamSpec);
EncryptedPrivateKeyInfo encinfo = new EncryptedPrivateKeyInfo(algparms, ciphertext);
FileOutputStream out3 = new FileOutputStream("server.key");
out3.write(Base64.encodeBase64(encryptedPkcs8, true));
out3.flush();
out3.close();
FileOutputStream out3 = new FileOutputStream("server.crt");
out3.write(Base64.encodeBase64(chain[0].getEncoded(), true));
out3.flush();
out3.close();
我将服务器证书和密钥加载到数据目录中,并且在启动服务器时,它使我陷入错误下方
FATAL: could not load private key file "server.key": unknown pbe algorithm
请帮我解决这个问题。 有没有人遇到这个错误? 任何帮助将不胜感激。
根据文档 ,可以对服务器密钥进行密码加密,但这意味着如果不手动输入密钥就无法启动PostgreSQL。 这意味着,除其他事项外,如果服务器进程失败,您将无法自动重启服务器,并且无法在启动时自动启动postgreSQL。 如果这是您要求的一部分,请仔细考虑并考虑权衡以及解决这些问题所必须采取的措施。
错误消息告诉您不支持用于密码保护服务器密钥的密码。 选择其他密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.