简体   繁体   English

PostgreSQL服务器无法启动

[英]PostgreSQL server not able to start

I am using PostgreSQL server for my application. 我正在为我的应用程序使用PostgreSQL服务器。 I am trying to implement secure connection using SSL certificate. 我正在尝试使用SSL证书实现安全连接。 I modified ssl property to "on" in postgresql.conf. 我在postgresql.conf中将ssl属性修改为“ on”。 I am generate self-signed certificate and key which is encrypted using the below java code, it uses pbe to encrypt the private key. 我生成使用以下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();

I loaded the server certificate and key into data directory and when I started the server, its throwing me below error 我将服务器证书和密钥加载到数据目录中,并且在启动服务器时,它使我陷入错误下方

    FATAL:  could not load private key file "server.key": unknown pbe algorithm

Please help me resolving this. 请帮我解决这个问题。 Has anyone faced this error ? 有没有人遇到这个错误? Any sort of help will be really appreciated. 任何帮助将不胜感激。

According to the docs , passphrase encryption of server keys is possible but it means that PostgreSQL cannot be started without entering the key manually. 根据文档 ,可以对服务器密钥进行密码加密,但这意味着如果不手动输入密钥就无法启动PostgreSQL。 This means, among other things that you cannot automatically restart the server process if it fails and you cannot automatically start postgreSQL on boot. 这意味着,除其他事项外,如果服务器进程失败,您将无法自动重启服务器,并且无法在启动时自动启动postgreSQL。 If this is a part of your requirements please think about it very carefully and consider the tradeoff and what you have to do to address these problems. 如果这是您要求的一部分,请仔细考虑并考虑权衡以及解决这些问题所必须采取的措施。

The error message is telling you that the cypher used to passphrase-protect the server key is not supported. 错误消息告诉您不支持用于密码保护服务器密钥的密码。 Choose a different cypher. 选择其他密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM