removing password from rsa private key

后端 未结 2 996
天涯浪人
天涯浪人 2020-12-02 01:50

Here\'s how I\'d do it with phpseclib (which works):

setPassword(\'password\');
$resul         


        
2条回答
  •  既然无缘
    2020-12-02 02:28

    Might find further info by looking into the cause of the error:

    if ($pkey === false) {
      echo openssl_error_string();
      exit('FAILURE');
    }
    

    Edit: Given the error "PEM_read_bio:bad end line" here is the portion of OpenSSL source which triggers:

    [...]
    if ((strncmp(buf,"-----END ",9) != 0) ||
            (strncmp(nameB->data,&(buf[9]),i) != 0) ||
            (strncmp(&(buf[9+i]),"-----\n",6) != 0)) {
    
            PEMerr(PEM_F_PEM_READ_BIO,PEM_R_BAD_END_LINE);
            goto err;
            }
    [...]
    

    Looking at your code I suspect you'll need a newline char appended to the end of the private key string.

提交回复
热议问题