This commit is contained in:
qubit 2011-08-29 03:24:53 +05:30
parent 8bc7e301d1
commit 51b24c3628
4 changed files with 11 additions and 9 deletions

View File

@ -15,7 +15,8 @@ struct rdp_certdata
{ {
char* thumbprint; char* thumbprint;
char* hostname; char* hostname;
} };
struct rdp_certstore struct rdp_certstore
{ {
FILE* fp; FILE* fp;
@ -29,13 +30,13 @@ struct rdp_certstore
void certstore_create(rdpCertstore* certstore); void certstore_create(rdpCertstore* certstore);
void certstore_open(rdpCertstore* certstore); void certstore_open(rdpCertstore* certstore);
void certstore_load(rdpCertstore* certstore); void certstore_load(rdpCertstore* certstore);
void certstore_close(rdpcertstore* certstore); void certstore_close(rdpCertstore* certstore);
char* get_local_certloc(); char* get_local_certloc();
rdpCertdata* certdata_new(char* host_name,char* fingerprint); rdpCertdata* certdata_new(char* host_name,char* fingerprint);
void certdata_free(rdpCertdata* certdata); void certdata_free(rdpCertdata* certdata);
void certstore_init(rdpCertstore* certstore); void certstore_init(rdpCertstore* certstore);
rdpCertstore* certstore_new(rdpCertdata* certdata); rdpCertstore* certstore_new(rdpCertdata* certdata);
void certstore_free(rdpCertsore* certstore); void certstore_free(rdpCertstore* certstore);
int match_certdata(rdpCertdata* certdata); int match_certdata(rdpCertstore* certstore);
void print_certdata(rdpCertstore* certstore); void print_certdata(rdpCertstore* certstore);
#endif /* __CERTSTORE_UTILS_H */ #endif /* __CERTSTORE_UTILS_H */

View File

@ -41,7 +41,6 @@
#define EXPONENT_MAX_SIZE 4 #define EXPONENT_MAX_SIZE 4
#define MODULUS_MAX_SIZE 64 #define MODULUS_MAX_SIZE 64
#define CA_LOCAL_PATH ".freerdp/cacert"
#include <freerdp/freerdp.h> #include <freerdp/freerdp.h>
#include <freerdp/utils/blob.h> #include <freerdp/utils/blob.h>
@ -90,6 +89,7 @@ void crypto_cert_printinfo(X509* xcert);
void crypto_cert_free(CryptoCert cert); void crypto_cert_free(CryptoCert cert);
boolean x509_verify_cert(CryptoCert cert); boolean x509_verify_cert(CryptoCert cert);
boolean crypto_cert_verify(CryptoCert server_cert, CryptoCert cacert); boolean crypto_cert_verify(CryptoCert server_cert, CryptoCert cacert);
rdpCertdata* crypto_get_certdata(X509 *xcert,char* hostname);
boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key); boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key);
void crypto_rsa_encrypt(uint8* input, int length, uint32 key_length, uint8* modulus, uint8* exponent, uint8* output); void crypto_rsa_encrypt(uint8* input, int length, uint32 key_length, uint8* modulus, uint8* exponent, uint8* output);

View File

@ -254,14 +254,14 @@ int tls_verify_certificate(CryptoCert cert,char* hostname)
ret=x509_verify_cert(cert); ret=x509_verify_cert(cert);
if(!ret) if(!ret)
{ {
Certdata* certdata; rdpCertdata* certdata;
certdata=crypto_get_certdata(cert->px509,hostname); certdata=crypto_get_certdata(cert->px509,hostname);
Certstore* certstore=certstore_new(certdata); rdpCertstore* certstore=certstore_new(certdata);
if(match_certdata(certstore)==0) if(match_certdata(certstore)==0)
goto end; goto end;
if(certstore->match==1) if(certstore->match==1)
{ {
crypto_cert_printinfo(cert->x509); crypto_cert_printinfo(cert->px509);
char answer; char answer;
while(1) while(1)
{ {
@ -286,8 +286,8 @@ int tls_verify_certificate(CryptoCert cert,char* hostname)
} }
end: end:
certstore_free(certstore); certstore_free(certstore);
return 0;
} }
return 0;
} }
void tls_print_cert_error() void tls_print_cert_error()

View File

@ -34,6 +34,7 @@ set(FREERDP_UTILS_SRCS
profiler.c profiler.c
rail.c rail.c
registry.c registry.c
certstore.c
semaphore.c semaphore.c
sleep.c sleep.c
stopwatch.c stopwatch.c