🐛 Fix certificate errors
This commit is contained in:
parent
8031543062
commit
23093b1505
2 changed files with 6 additions and 8 deletions
|
@ -36,8 +36,8 @@ int main() {
|
||||||
|
|
||||||
// Load the server's certificate into context
|
// Load the server's certificate into context
|
||||||
if (SSL_CTX_load_verify_locations(
|
if (SSL_CTX_load_verify_locations(
|
||||||
ctx, "~/git/mogens_og_karen/ssl/server.crt", nullptr) <= 0) {
|
ctx, "./ssl/server.crt", nullptr) <= 0) {
|
||||||
// TODO Handle error
|
cout << "SSL load failed" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create SSL object
|
// Create SSL object
|
||||||
|
@ -81,7 +81,7 @@ int main() {
|
||||||
cout << endl;
|
cout << endl;
|
||||||
message.username = "Client 1";
|
message.username = "Client 1";
|
||||||
|
|
||||||
SSL_write(ssl, message.toString().data(), 0);
|
SSL_write(ssl, message.toString().data(), strlen(message.toString().data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
@ -25,14 +24,13 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load certificate
|
// Load certificate
|
||||||
if (SSL_CTX_use_certificate_file(ctx,
|
if (SSL_CTX_use_certificate_file(ctx, "./ssl/server.crt",
|
||||||
"~/git/mogens_og_karen/ssl/server.crt",
|
|
||||||
SSL_FILETYPE_PEM) <= 0) {
|
SSL_FILETYPE_PEM) <= 0) {
|
||||||
// TODO Handle error
|
// TODO Handle error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load certificate private key
|
// Load certificate private key
|
||||||
if (SSL_CTX_use_PrivateKey_file(ctx, "~/git/mogens_og_karen/ssl/server.key",
|
if (SSL_CTX_use_PrivateKey_file(ctx, "./ssl/server.key",
|
||||||
SSL_FILETYPE_PEM) <= 0) {
|
SSL_FILETYPE_PEM) <= 0) {
|
||||||
// TODO Handle error
|
// TODO Handle error
|
||||||
}
|
}
|
||||||
|
@ -74,7 +72,7 @@ int main() {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char buffer[1024] = {0};
|
char buffer[1024] = {0};
|
||||||
SSL_read(ssl, buffer, 0);
|
SSL_read(ssl, buffer, sizeof(buffer) - 1);
|
||||||
|
|
||||||
if (strlen(buffer) <= 0) {
|
if (strlen(buffer) <= 0) {
|
||||||
cout << "Client seems to have just straight up left :(" << endl;
|
cout << "Client seems to have just straight up left :(" << endl;
|
||||||
|
|
Loading…
Reference in a new issue