-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
SSL fixes for validator list (RIPD-1558) #2275
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2016 Ripple Labs Inc. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stale date |
||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#ifndef RIPPLE_NET_REGISTER_SSL_CERTS_H_INCLUDED | ||
#define RIPPLE_NET_REGISTER_SSL_CERTS_H_INCLUDED | ||
|
||
#include <boost/asio/ssl/context.hpp> | ||
|
||
namespace ripple { | ||
/** Register default SSL certificates. | ||
|
||
Register the system default SSL root certificates. On linux/mac, | ||
this just calls asio's `set_default_verify_paths` to look in standard | ||
operating system locations. On windows, it uses the OS certificate | ||
store accessible via CryptoAPI. | ||
*/ | ||
void | ||
registerSSLCerts(boost::asio::ssl::context&, boost::system::error_code&); | ||
|
||
} // namespace ripple | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2012, 2013 Ripple Labs Inc. | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
#include <BeastConfig.h> | ||
#include <ripple/net/RegisterSSLCerts.h> | ||
#if BEAST_WINDOWS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can use boost predef instead. |
||
#include <wincrypt.h> | ||
#endif | ||
|
||
namespace ripple { | ||
|
||
void | ||
registerSSLCerts(boost::asio::ssl::context& ctx, boost::system::error_code& ec) | ||
{ | ||
#if BEAST_WINDOWS | ||
HCERTSTORE hStore = CertOpenSystemStore(0, "ROOT"); | ||
if (hStore == NULL) | ||
{ | ||
return; | ||
} | ||
|
||
X509_STORE* store = X509_STORE_new(); | ||
PCCERT_CONTEXT pContext = NULL; | ||
while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != NULL) | ||
{ | ||
X509* x509 = d2i_X509( | ||
NULL, | ||
(const unsigned char**)&pContext->pbCertEncoded, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pContext->cbCertEncoded); | ||
if (x509 != NULL) | ||
{ | ||
X509_STORE_add_cert(store, x509); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how this would fail, but should we log if it does? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth doing. I'll look into making an error_code. |
||
X509_free(x509); | ||
} | ||
} | ||
|
||
CertFreeCertificateContext(pContext); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, will fix. |
||
CertCloseStore(hStore, 0); | ||
|
||
SSL_CTX_set_cert_store(ctx.native_handle(), store); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm, the reason we don't use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. I believe since we create the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, it looks like the reference counted version is not available in the 1.0.* versions we are using. |
||
#else | ||
|
||
ctx.set_default_verify_paths(ec); | ||
#endif | ||
} | ||
|
||
} // namespace ripple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: misaligned