2012-04-16 5 views

답변

0

이 시도 :

 EVP_PKEY *pkey; 
     FILE *f = fopen("<path for your PEM or DER encoded key>", "rb"); 
     if (f == NULL){ 
       // error handling... 
     } 
    //if your key is PEM encoded use this 
     pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL); // pkey now contains the pubKey. 
    //We are passing NULL to the others parameters because we dont need password to read a public key 

    //if your key is DER encoded use this 
     pkey = d2i_PUBKEY_fp(f, NULL); 

     if (pkey == NULL){ 
       // error handling... 
     } 

내가 테스트를 일부러하지만 작동합니다.

+0

이 키는 개인 키를 저장하고 공개 키는 무엇이며 질문에 언급 된 파일을 사용하여 초기화하는 방법은 무엇입니까? – Jake

+0

EVP_PKEY *pkey; FILE *f = fopen("", "rb"); if (f == NULL){ // error handling... } \t //if your key is PEM encoded use this pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL); // pkey now contains the pubKey. \t //We are passing NULL to the others parameters because we dont need password to read a public key \t //if your key is DER encoded use this pkey = d2i_PUBKEY_fp(f, NULL); if (pkey == NULL){ // error handling... } 나는 테스트를하지는 않았지만 작동해야합니다. – Giovani

+0

키가 * .key 형식이면? – Jake

관련 문제