Fix changelog email address
[freerdp-ubuntu-pcb-backport.git] / libfreerdp-core / tls.h
1 /**
2  * FreeRDP: A Remote Desktop Protocol Client
3  * Transport Layer Security
4  *
5  * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #ifndef __TLS_H
21 #define __TLS_H
22
23 #include "crypto.h"
24 #include "certificate.h"
25
26 #include <openssl/ssl.h>
27 #include <openssl/err.h>
28
29 #include <freerdp/types.h>
30 #include <freerdp/utils/stream.h>
31
32 typedef struct rdp_tls rdpTls;
33
34 struct rdp_tls
35 {
36         SSL* ssl;
37         int sockfd;
38         SSL_CTX* ctx;
39         rdpSettings* settings;
40         rdpCertificateStore* certificate_store;
41 };
42
43 boolean tls_connect(rdpTls* tls);
44 boolean tls_accept(rdpTls* tls, const char* cert_file, const char* privatekey_file);
45 boolean tls_disconnect(rdpTls* tls);
46
47 int tls_read(rdpTls* tls, uint8* data, int length);
48 int tls_write(rdpTls* tls, uint8* data, int length);
49
50 CryptoCert tls_get_certificate(rdpTls* tls);
51 boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname);
52 void tls_print_certificate_error(char* hostname, char* fingerprint);
53 void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name, char** alt_names, int alt_names_count);
54
55 boolean tls_print_error(char* func, SSL* connection, int value);
56
57 rdpTls* tls_new(rdpSettings* settings);
58 void tls_free(rdpTls* tls);
59
60 #endif /* __TLS_H */