Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the platform native APIs with C++ SSL transport #2063

Merged
merged 52 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e299cf6
Use ssl native API
pepone Apr 17, 2024
6b9286f
Checkpoint
pepone Apr 19, 2024
ddb1fb4
Checkpoint
pepone Apr 19, 2024
c36953a
SChannel fixes
pepone Apr 21, 2024
f176d7d
SChannel certificate validation fixes
pepone Apr 22, 2024
b18f2f5
SecureTransport fixes
pepone Apr 23, 2024
be82bae
Add TLS 1.2 protocol name
pepone Apr 23, 2024
c877a81
OpenSSL fixes
pepone Apr 24, 2024
ed9711b
Cleanup
pepone Apr 24, 2024
319ac21
Merge remote-tracking branch 'origin/main' into ssl-native
pepone Apr 24, 2024
ae94cd4
Cleanup
pepone Apr 24, 2024
9d13c39
Merge remote-tracking branch 'origin/main' into ssl-native
pepone Apr 25, 2024
2dfc388
Checkpoint
pepone Apr 25, 2024
1e48e73
Additional fixes
pepone Apr 25, 2024
02ac138
Fix clang format
pepone Apr 25, 2024
d61d27f
Doc comment fixes
pepone Apr 25, 2024
3588bd4
Script language fixes
pepone Apr 25, 2024
512c596
Checkpoint
pepone Apr 25, 2024
fbc6712
Fix Swift tests
pepone Apr 25, 2024
f4e9f30
Restore EOF_WHILE_READING
pepone Apr 26, 2024
c9ff80c
SChannel fixes
pepone Apr 26, 2024
f48f3cf
Retrieve OpenSSL peer certificate chain
pepone Apr 26, 2024
78c2921
OpenSSL fixes
pepone Apr 26, 2024
42bc483
Fix clang-format
pepone Apr 25, 2024
5030a1e
macOS fixes
pepone Apr 26, 2024
ae67d2f
Add default OpenSSL certificate verification callback
pepone Apr 26, 2024
4b2a152
Merge remote-tracking branch 'origin/main' into ssl-native
pepone Apr 26, 2024
f84b577
SecureTransport fixes
pepone Apr 26, 2024
54c4b49
Schannel fixes
pepone Apr 29, 2024
4d7a2f6
SecureTransport fixes
pepone Apr 29, 2024
dbc3234
Cleanup
pepone Apr 29, 2024
b58840b
SecureTransport & OpenSSL fixes
pepone Apr 30, 2024
460129a
Checkpoint
pepone Apr 30, 2024
0bec18e
Merge remote-tracking branch 'origin/main' into ssl-native
pepone Apr 30, 2024
89d2d1b
SecureTransport updates
pepone May 1, 2024
aec11f5
Improve OpenSSL usage doc comments
pepone May 1, 2024
1607c42
Retain/Release SecureTransport trusted roots
pepone May 1, 2024
bd70794
OpenSSL bug with bogus _sslCtx reference
pepone May 1, 2024
7c8290f
SChannel updates
pepone May 2, 2024
ab5d208
Update cpp/src/IceSSL/OpenSSLTransceiverI.cpp
pepone May 3, 2024
2a6c820
Update cpp/src/IceSSL/SecureTransportTransceiverI.cpp
pepone May 3, 2024
4326856
Update cpp/src/IceSSL/SecureTransportTransceiverI.cpp
pepone May 3, 2024
063dbc8
Update cpp/src/IceSSL/SChannelEngine.cpp
pepone May 3, 2024
d8851b4
Update cpp/src/IceSSL/OpenSSLTransceiverI.cpp
pepone May 3, 2024
79426bd
Update cpp/src/IceSSL/SChannelTransceiverI.cpp
pepone May 3, 2024
ed26e4e
Review fixes
pepone May 3, 2024
97c3dc6
More review fixes
pepone May 3, 2024
e0bf553
Fix typo
pepone May 3, 2024
f406d54
Cleanup
pepone May 3, 2024
3f0b970
Merge remote-tracking branch 'origin/main' into ssl-native
pepone May 3, 2024
456022a
Build fixes
pepone May 3, 2024
01f506f
Additional review fixes
pepone May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN set -eux \
&& sudo dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& sudo apt update \
&& sudo apt-get install -y python3 python3-dev python3-passlib ruby-full \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is gdb necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use it to debug the tests, I think it is fine for a development container.

&& sudo apt-get install -y python3 python3-dev python3-passlib ruby-full gdb \
&& sudo apt-get install -y libbluetooth-dev libbz2-dev libdbus-1-dev libedit-dev libexpat1-dev liblmdb-dev libmcpp-dev libssl-dev libsystemd-dev \
&& sudo rm -rf /var/lib/apt/lists/* \
&& sudo apt-get clean
52 changes: 0 additions & 52 deletions cpp/include/Ice/Certificate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,6 @@

namespace IceSSL
{
/**
bernardnormier marked this conversation as resolved.
Show resolved Hide resolved
* The reason for an IceSSL certificate verification failure.
*/
enum class TrustError : std::uint8_t
{
/** The certification verification succeed */
NoError = 0,
/** The certificate chain length is greater than the specified maximum depth **/
ChainTooLong,
/** The X509 chain is invalid because a certificate has excluded a name constraint **/
HasExcludedNameConstraint,
/** The certificate has an undefined name constraint **/
HasNonDefinedNameConstraint,
/** The certificate has a non permitted name constraint **/
HasNonPermittedNameConstraint,
/** The certificate does not support a critical extension **/
HasNonSupportedCriticalExtension,
/** The certificate does not have a supported name constraint or has a name constraint that is unsupported **/
HasNonSupportedNameConstraint,
/** A host name mismatch has occurred **/
HostNameMismatch,
/** The X509 chain is invalid due to invalid basic constraints **/
InvalidBasicConstraints,
/** The X509 chain is invalid due to an invalid extension **/
InvalidExtension,
/** The X509 chain is invalid due to invalid name constraints **/
InvalidNameConstraints,
/** The X509 chain is invalid due to invalid policy constraints **/
InvalidPolicyConstraints,
/** The supplied certificate cannot be used for the specified purpose **/
InvalidPurpose,
/** The X509 chain is invalid due to an invalid certificate signature **/
InvalidSignature,
/** The X509 chain is not valid due to an invalid time value, such as a value that indicates an expired
certificate **/
InvalidTime,
/** The certificate is explicitly not trusted **/
NotTrusted,
/** The X509 chain could not be built up to the root certificate **/
PartialChain,
/** It is not possible to determine whether the certificate has been revoked **/
RevocationStatusUnknown,
/** The X509 chain is invalid due to a revoked certificate **/
Revoked,
/** The X509 chain is invalid due to an untrusted root certificate **/
UntrustedRoot,
/** The X509 chain is invalid due to other unknown failure **/
UnknownTrustFailure,
};

ICE_API std::string getTrustErrorDescription(TrustError);

/**
* The key usage "digitalSignature" bit is set
*/
Expand Down
425 changes: 425 additions & 0 deletions cpp/include/Ice/ClientAuthenticationOptions.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice API!

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions cpp/include/Ice/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Plugin.h"
#include "Properties.h"
#include "Proxy.h"
#include "ServerAuthenticationOptions.h"

#ifdef ICE_SWIFT
# include <dispatch/dispatch.h>
Expand Down Expand Up @@ -141,12 +142,15 @@ namespace Ice
* communicator as is used by the adapter. Attempts to create a named object adapter for which no configuration
* can be found raise InitializationException.
* @param name The object adapter name.
* @param serverAuthenticationOptions The SSL configuration properties for server connections.
* @return The new object adapter.
* @see #createObjectAdapterWithEndpoints
* @see ObjectAdapter
* @see Properties
*/
ObjectAdapterPtr createObjectAdapter(const std::string& name);
ObjectAdapterPtr createObjectAdapter(
const std::string& name,
const std::optional<SSL::ServerAuthenticationOptions>& serverAuthenticationOptions = std::nullopt);

/**
* Create a new object adapter with endpoints. This operation sets the property
Expand All @@ -155,12 +159,16 @@ namespace Ice
* name.
* @param name The object adapter name.
* @param endpoints The endpoints for the object adapter.
* @param serverAuthenticationOptions The SSL configuration properties for server connections.
* @return The new object adapter.
* @see #createObjectAdapter
* @see ObjectAdapter
* @see Properties
*/
ObjectAdapterPtr createObjectAdapterWithEndpoints(const std::string& name, const std::string& endpoints);
ObjectAdapterPtr createObjectAdapterWithEndpoints(
const std::string& name,
const std::string& endpoints,
const std::optional<SSL::ServerAuthenticationOptions>& serverAuthenticationOptions = std::nullopt);

/**
* Create a new object adapter with a router. This operation creates a routed object adapter.
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/Ice/Ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// We don't need to see the following headers when building the generated code.

# include "Certificate.h"
# include "ClientAuthenticationOptions.h"
# include "Communicator.h"
# include "Connection.h"
# include "IconvStringConverter.h"
Expand All @@ -38,6 +39,7 @@
# include "SSLConnectionInfo.h"
# include "SSLEndpointInfo.h"
# include "ServantLocator.h"
# include "ServerAuthenticationOptions.h"
# include "SlicedData.h"
# include "StringConverter.h"
# include "UUID.h"
Expand Down
7 changes: 7 additions & 0 deletions cpp/include/Ice/Initialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define ICE_INITIALIZE_H

#include "BatchRequest.h"
#include "ClientAuthenticationOptions.h"
#include "CommunicatorF.h"
#include "Connection.h"
#include "Ice/BuiltinSequences.h"
Expand Down Expand Up @@ -330,6 +331,12 @@ namespace Ice
* The value factory manager.
*/
ValueFactoryManagerPtr valueFactoryManager;

/**
* The authentication options for SSL client connections. When set, the SSL transport ignores all IceSSL
* configuration properties and uses the provided options.
*/
std::optional<SSL::ClientAuthenticationOptions> clientAuthenticationOptions;
};

/**
Expand Down
39 changes: 39 additions & 0 deletions cpp/include/Ice/SSLConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#ifndef ICE_SSL_CONFIG
#define ICE_SSL_CONFIG

#if defined(_WIN32)
# define ICE_USE_SCHANNEL
// We need to include windows.h before wincrypt.h.
// clang-format off
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <windows.h>
# include <wincrypt.h>
// clang-format on
// SECURITY_WIN32 or SECURITY_KERNEL are defined before including security.h indicating who is compiling the code.
# ifdef SECURITY_WIN32
# undef SECURITY_WIN32
# endif
# ifdef SECURITY_KERNEL
# undef SECURITY_KERNEL
# endif
# define SECURITY_WIN32 1
# include <schannel.h>
# include <security.h>
# include <sspi.h>
# undef SECURITY_WIN32
#elif defined(__APPLE__)
# define ICE_USE_SECURE_TRANSPORT
# include <Security/SecureTransport.h>
# include <Security/Security.h>
#else
# define ICE_USE_OPENSSL
# include <openssl/ssl.h>
#endif

#endif
21 changes: 2 additions & 19 deletions cpp/include/Ice/SSLConnectionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,16 @@ namespace IceSSL
* @param incoming Whether or not the connection is an incoming or outgoing connection.
* @param adapterName The name of the adapter associated with the connection.
* @param connectionId The connection id.
* @param cipher The negotiated cipher suite.
* @param certs The certificate chain.
* @param verified The certificate chain verification status.
*/
ConnectionInfo(
const Ice::ConnectionInfoPtr& underlying,
bool incoming,
const std::string& adapterName,
const std::string& connectionId,
const std::string& cipher,
const std::vector<CertificatePtr>& certs,
bool verified)
const std::vector<CertificatePtr>& certs)
: Ice::ConnectionInfo(underlying, incoming, adapterName, connectionId),
cipher(cipher),
certs(certs),
verified(verified)
certs(certs)
{
}

Expand All @@ -57,21 +51,10 @@ namespace IceSSL
ConnectionInfo(const ConnectionInfo&) = delete;
ConnectionInfo& operator=(const ConnectionInfo&) = delete;

/**
* The negotiated cipher suite.
*/
std::string cipher;
/**
* The certificate chain.
*/
std::vector<CertificatePtr> certs;
/**
* The certificate chain verification status.
*/
bool verified;

TrustError errorCode;
std::string host;
};
}

Expand Down
Loading