mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 04:04:39 +02:00
added standard license headers, switched to C-style comments
This commit is contained in:
@@ -1,4 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# build-wolfssl-framework.sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
|
#
|
||||||
|
# This file is part of wolfSSL.
|
||||||
|
#
|
||||||
|
# wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
|
||||||
|
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
WOLFSSL_DIR=$(pwd)/../../
|
WOLFSSL_DIR=$(pwd)/../../
|
||||||
|
@@ -1,15 +1,29 @@
|
|||||||
//
|
/* ContentView.swift
|
||||||
// ContentView.swift
|
*
|
||||||
// wolfssl-multiplatform
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
//
|
*
|
||||||
// Created by Brett Nicholas on 7/11/23.
|
* This file is part of wolfSSL.
|
||||||
//
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
// Call our test function in the initialization of the view
|
/* Call our test function in the initialization of the view */
|
||||||
init() {
|
init() {
|
||||||
wolfssl_test();
|
wolfssl_test();
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,24 @@
|
|||||||
|
/* simple_client_example.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include "simple_client_example.h"
|
#include "simple_client_example.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -5,7 +26,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_USER_SETTINGS
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
#endif
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
|
|
||||||
#define SERVER_HOST "www.wolfssl.com"
|
#define SERVER_HOST "www.wolfssl.com"
|
||||||
@@ -17,7 +41,7 @@ int simple_client_example(void)
|
|||||||
WOLFSSL* ssl;
|
WOLFSSL* ssl;
|
||||||
int sockfd, ret;
|
int sockfd, ret;
|
||||||
|
|
||||||
// Resolve the server address
|
/* Resolve the server address */
|
||||||
struct addrinfo hints, *server_addr;
|
struct addrinfo hints, *server_addr;
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
@@ -29,7 +53,7 @@ int simple_client_example(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a TCP socket
|
/* Create a TCP socket */
|
||||||
sockfd = socket(server_addr->ai_family, server_addr->ai_socktype, server_addr->ai_protocol);
|
sockfd = socket(server_addr->ai_family, server_addr->ai_socktype, server_addr->ai_protocol);
|
||||||
if (sockfd == -1) {
|
if (sockfd == -1) {
|
||||||
perror("Failed to create socket");
|
perror("Failed to create socket");
|
||||||
@@ -37,7 +61,7 @@ int simple_client_example(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to the server
|
/* Connect to the server */
|
||||||
ret = connect(sockfd, server_addr->ai_addr, server_addr->ai_addrlen);
|
ret = connect(sockfd, server_addr->ai_addr, server_addr->ai_addrlen);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
perror("Failed to connect to server");
|
perror("Failed to connect to server");
|
||||||
@@ -48,10 +72,10 @@ int simple_client_example(void)
|
|||||||
|
|
||||||
freeaddrinfo(server_addr);
|
freeaddrinfo(server_addr);
|
||||||
|
|
||||||
// Initialize wolfSSL library
|
/* Initialize wolfSSL library */
|
||||||
wolfSSL_Init();
|
wolfSSL_Init();
|
||||||
|
|
||||||
// Create a new SSL context
|
/* Create a new SSL context */
|
||||||
ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method());
|
ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method());
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
printf("Unable to create SSL context.\n");
|
printf("Unable to create SSL context.\n");
|
||||||
@@ -59,10 +83,10 @@ int simple_client_example(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load CA certificate into WOLFSSL_CTX
|
/* Load CA certificate into WOLFSSL_CTX
|
||||||
// NOTE: CERT_PATH macro is set relative to Xcode $(PROJECT_DIR) environment variable
|
* NOTE: CERT_PATH macro is set relative to Xcode $(PROJECT_DIR) environment variable
|
||||||
// in the preprocessor macros section of the project build settings to avoid hardcoding
|
* in the preprocessor macros section of the project build settings to avoid hardcoding
|
||||||
// a path in the source code. The CA cert is located at wolfssl/certs/wolfssl-website-ca.pem.
|
* a path in the source code. The CA cert is located at wolfssl/certs/wolfssl-website-ca.pem. */
|
||||||
if ((ret = wolfSSL_CTX_load_verify_locations(ctx, CERT_PATH, NULL)) != WOLFSSL_SUCCESS) {
|
if ((ret = wolfSSL_CTX_load_verify_locations(ctx, CERT_PATH, NULL)) != WOLFSSL_SUCCESS) {
|
||||||
printf("ERROR: failed to load %s, please check the file.\n", CERT_PATH);
|
printf("ERROR: failed to load %s, please check the file.\n", CERT_PATH);
|
||||||
wolfSSL_CTX_free(ctx);
|
wolfSSL_CTX_free(ctx);
|
||||||
@@ -70,7 +94,7 @@ int simple_client_example(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new SSL object
|
/* Create a new SSL object */
|
||||||
ssl = wolfSSL_new(ctx);
|
ssl = wolfSSL_new(ctx);
|
||||||
if (ssl == NULL) {
|
if (ssl == NULL) {
|
||||||
printf("Unable to create SSL object.\n");
|
printf("Unable to create SSL object.\n");
|
||||||
@@ -79,10 +103,10 @@ int simple_client_example(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the SSL object to the socket file descriptor
|
/* Attach the SSL object to the socket file descriptor */
|
||||||
wolfSSL_set_fd(ssl, sockfd);
|
wolfSSL_set_fd(ssl, sockfd);
|
||||||
|
|
||||||
// Perform the SSL handshake
|
/* Perform the SSL handshake */
|
||||||
ret = wolfSSL_connect(ssl);
|
ret = wolfSSL_connect(ssl);
|
||||||
if (ret != SSL_SUCCESS) {
|
if (ret != SSL_SUCCESS) {
|
||||||
printf("SSL connection failed: %d\n", wolfSSL_get_error(ssl, ret));
|
printf("SSL connection failed: %d\n", wolfSSL_get_error(ssl, ret));
|
||||||
@@ -92,14 +116,14 @@ int simple_client_example(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send an HTTP request
|
/* Send an HTTP request */
|
||||||
const char* request = "GET / HTTP/1.1\r\nHost: www.wolfssl.com\r\n\r\n";
|
const char* request = "GET / HTTP/1.1\r\nHost: www.wolfssl.com\r\n\r\n";
|
||||||
ret = wolfSSL_write(ssl, request, (int)strlen(request));
|
ret = wolfSSL_write(ssl, request, (int)strlen(request));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to send HTTP request.\n");
|
printf("Failed to send HTTP request.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive and print the server's response
|
/* Receive and print the server's response */
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
ret = wolfSSL_read(ssl, buffer, sizeof(buffer) - 1);
|
ret = wolfSSL_read(ssl, buffer, sizeof(buffer) - 1);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
@@ -109,7 +133,7 @@ int simple_client_example(void)
|
|||||||
printf("Failed to receive server response.\n");
|
printf("Failed to receive server response.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up and close the connection
|
/* Clean up and close the connection */
|
||||||
wolfSSL_shutdown(ssl);
|
wolfSSL_shutdown(ssl);
|
||||||
wolfSSL_free(ssl);
|
wolfSSL_free(ssl);
|
||||||
wolfSSL_CTX_free(ctx);
|
wolfSSL_CTX_free(ctx);
|
||||||
|
@@ -1,8 +1,23 @@
|
|||||||
//
|
/* simple_client_example.h
|
||||||
// simple_client_example.h
|
*
|
||||||
// wolfssl-multiplatform
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
//
|
*
|
||||||
//
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef simple_client_example_h
|
#ifndef simple_client_example_h
|
||||||
#define simple_client_example_h
|
#define simple_client_example_h
|
||||||
|
@@ -1,4 +1,25 @@
|
|||||||
//
|
/* wolfssl-multiplatform-Bridging-Header.h
|
||||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
*
|
||||||
//
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use this file to import your target's public headers that you would like to expose to Swift.
|
||||||
|
*/
|
||||||
#import "wolfssl_test_driver.h"
|
#import "wolfssl_test_driver.h"
|
||||||
|
@@ -1,9 +1,23 @@
|
|||||||
//
|
/* wolfssl_multiplatformApp.swift
|
||||||
// wolfssl_multiplatformApp.swift
|
*
|
||||||
// wolfssl-multiplatform
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
//
|
*
|
||||||
// Created by Brett Nicholas on 7/11/23.
|
* This file is part of wolfSSL.
|
||||||
//
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
@@ -1,13 +1,29 @@
|
|||||||
//
|
/* wolfssl_test_driver.c
|
||||||
// wolfssl_test.c
|
*
|
||||||
// wolfssl-multiplatform
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
//
|
*
|
||||||
// Created by Brett Nicholas on 7/11/23.
|
* This file is part of wolfSSL.
|
||||||
//
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include "wolfssl_test_driver.h"
|
#include "wolfssl_test_driver.h"
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_USER_SETTINGS
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
#endif
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
@@ -1,9 +1,23 @@
|
|||||||
//
|
/* wolfssl_test_driver.h
|
||||||
// wolfssl_test.h
|
*
|
||||||
// wolfssl-multiplatform
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
||||||
//
|
*
|
||||||
// Created by Brett Nicholas on 7/11/23.
|
* This file is part of wolfSSL.
|
||||||
//
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef wolfssl_test_driver_h
|
#ifndef wolfssl_test_driver_h
|
||||||
#define wolfssl_test_driver_h
|
#define wolfssl_test_driver_h
|
||||||
|
Reference in New Issue
Block a user