Java 응용 프로그램 용 Java 및 Native C에서 OpenSSL을 사용하려고합니다. 내가 지금까지 무슨 짓을OpenSSL이 스마트 카드에서 수행 할 RSA_sign을 무시합니다.
:
처럼 초기화 OpenSSL을 :
ret = SSL_library_init();
SSL_load_error_strings();
ctx = SSL_CTX_new(SSLv23_method());
ret = SSL_CTX_use_certificate(ctx, sc_cert); // sc_cert is the Smart Cards auth certificate -> this is working!
_ssl = SSL_new(ctx);
지금 내가 rsa_sign 기능 (내 자신의)을 설정하는 콜백 tryed : 지금
RSA_METHOD *rsameth = RSA_get_default_method();
rsameth -> rsa_verify = &sc_rsa_verify; // Just returns 1, but gets never called.
rsameth -> rsa_sign = &sc_rsa_sign;
rsameth -> flags |= RSA_FLAG_SIGN_VER; // If i would use 0x1FF my function gets called, why?
RSA_set_default_method(rsameth);
_rsa = RSA_new(); // handle error
// No need to do this: RSA_set_default_method already did that!
//_rsa -> meth = rsameth;
//_rsa -> flags |= RSA_FLAG_SIGN_VER;
//RSA_set_method(_rsa, rsameth);
ret = SSL_use_RSAPrivateKey(_ssl, _rsa);
RSA_set_default_method(rsameth);
을 내 마지막 단계 :
sbio = BIO_new_socket(sock, BIO_NOCLOSE); // Sock had been created before and is working!
SSL_set_bio(_ssl, sbio, sbio);
if(_session) SSL_set_session(_ssl, _session);
ret = SSL_connect(_ssl);
- 없음 오류 : 23,414,지금 SSL_connect 후 내가 하나를 얻을 오류 : 1409441B : SSL 루틴 : SSL3_READ_BYTES : TLSv1의 경고 해독 오류, 때 내 자신의 RSA_sign 내 자신의 RSA_sign (sc_rsa_sign)는
- 또는 호출되지 않은 경우
jbyteArray to_crypt = (*_env) -> NewByteArray(_env, m_length); (*_env) -> SetByteArrayRegion(_env, to_crypt, 0, m_length, m); // Jump into Java and do the crypt on card. This is working! jbyteArray crypted = (*_env) -> CallObjectMethod(_env, _obj, _callback_cryptoncard, to_crypt); // I also read that siglen should be the size of RSA_size(rsa), thus rsa -> n is not allowed to be NULL here. But it is! What is wrong here? //int size = RSA_size(rsa); //sigret = malloc(size); // Obtain bytes from Java. Working (right size and crypted)! *siglen = (*_env) -> GetArrayLength(_env, crypted); sigret = (*_env) -> GetByteArrayElements(_env, crypted, NULL); //(*_env) -> ReleaseByteArrayElements(_env, crypted, sigret, 0); return 1;
그게 전부 내가 지금까지했던 : (sc_rsa_sign)은 이제 내 자신의 RSA_sign (sc_rsa_sign) 함수 내에서 좀 걸릴 수 있습니다
을 불렀다. 지금 몇 주 동안 이걸로 고투하고있어! 누군가가 나를 도울 수 있기를 바랍니다!
자신의 코드를 사용할 때 ClientHello SSL 메시지에서 올바른 인증서를 서버로 보내십니까? – Robert
그 원인은 다음과 같습니다. 1409441B : SSL 루틴 : SSL3_READ_BYTES : tlsv1 alert decrypt error? 기억해 두십시오 : 내 자신의 rsa_verify가 호출되지 않는다면 SSL_connect (SSL_connect는 1을 반환하고 Im은 SSL_read/SSL_write를 호출 할 수 있습니다) – ILadis
_RSA_set_default_method() "..."이것은 ENGINE이없는 동안에 만 적용됩니다 RSA의 기본값으로 설정되어 있으므로이 기능은 더 이상 권장되지 않습니다. _ ENA가 RSA의 기본값으로 설정되었는지 어떻게 확인할 수 있습니까? 그게 문제가 되겠습니까? ** rsa_priv_enc ** 함수를 재정의 할 수도 있습니다. 하지만 절대로 불리지 않는다! – ILadis