summaryrefslogtreecommitdiffstats
path: root/vendor/openssl-probe
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
commit10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch)
treebdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/openssl-probe
parentReleasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff)
downloadrustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz
rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/openssl-probe')
-rw-r--r--vendor/openssl-probe/.cargo-checksum.json1
-rw-r--r--vendor/openssl-probe/Cargo.lock7
-rw-r--r--vendor/openssl-probe/Cargo.toml20
-rw-r--r--vendor/openssl-probe/LICENSE-APACHE201
-rw-r--r--vendor/openssl-probe/LICENSE-MIT25
-rw-r--r--vendor/openssl-probe/README.md33
-rw-r--r--vendor/openssl-probe/examples/probe.rs6
-rw-r--r--vendor/openssl-probe/src/lib.rs136
8 files changed, 429 insertions, 0 deletions
diff --git a/vendor/openssl-probe/.cargo-checksum.json b/vendor/openssl-probe/.cargo-checksum.json
new file mode 100644
index 000000000..79de57e00
--- /dev/null
+++ b/vendor/openssl-probe/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.lock":"ad8c068c0dffdd9d57068d1e8ddb5cb0354070e06087bef5b37fdda87b1a9ef9","Cargo.toml":"386e7ac7a1a7bc851e9e611e14396b6b3ead5bea731fac8866bd5db79f77943e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"92bce73b5b1e41134e103fc07974aeab78866c7e0335a613436d3de85f0f8d04","examples/probe.rs":"78fd7274bd050c3d53b0c855be121d2388d4b8ac2fa0e52160a55ddc65e2c2f0","src/lib.rs":"7915d920e7e388586a93376fc8860b4eb5117da2f53f78d7bffa4e08e9f3426a"},"package":"ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"} \ No newline at end of file
diff --git a/vendor/openssl-probe/Cargo.lock b/vendor/openssl-probe/Cargo.lock
new file mode 100644
index 000000000..5779dcb9f
--- /dev/null
+++ b/vendor/openssl-probe/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "openssl-probe"
+version = "0.1.5"
diff --git a/vendor/openssl-probe/Cargo.toml b/vendor/openssl-probe/Cargo.toml
new file mode 100644
index 000000000..1bfa856ab
--- /dev/null
+++ b/vendor/openssl-probe/Cargo.toml
@@ -0,0 +1,20 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+name = "openssl-probe"
+version = "0.1.5"
+authors = ["Alex Crichton <alex@alexcrichton.com>"]
+description = "Tool for helping to find SSL certificate locations on the system for OpenSSL\n"
+homepage = "https://github.com/alexcrichton/openssl-probe"
+readme = "README.md"
+license = "MIT/Apache-2.0"
+repository = "https://github.com/alexcrichton/openssl-probe"
diff --git a/vendor/openssl-probe/LICENSE-APACHE b/vendor/openssl-probe/LICENSE-APACHE
new file mode 100644
index 000000000..16fe87b06
--- /dev/null
+++ b/vendor/openssl-probe/LICENSE-APACHE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/vendor/openssl-probe/LICENSE-MIT b/vendor/openssl-probe/LICENSE-MIT
new file mode 100644
index 000000000..39e0ed660
--- /dev/null
+++ b/vendor/openssl-probe/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright (c) 2014 Alex Crichton
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/vendor/openssl-probe/README.md b/vendor/openssl-probe/README.md
new file mode 100644
index 000000000..b0d7ab0c2
--- /dev/null
+++ b/vendor/openssl-probe/README.md
@@ -0,0 +1,33 @@
+# openssl-probe
+
+Tool for helping to find SSL certificate locations on the system for OpenSSL
+
+[![Crates.io](https://img.shields.io/crates/v/openssl-probe.svg?maxAge=2592000)](https://crates.io/crates/openssl-probe)
+[![docs.rs](https://docs.rs/openssl-probe/badge.svg)](https://docs.rs/openssl-probe/)
+
+## Usage
+
+First, add this to your `Cargo.toml`:
+
+```toml
+[dependencies]
+openssl-probe = "0.1.2"
+```
+
+Then add this to your crate:
+
+```rust
+extern crate openssl_probe;
+
+fn main() {
+ openssl_probe::init_ssl_cert_env_vars();
+ //... your code
+}
+```
+
+## License
+
+`openssl-probe` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0),
+with portions covered by various BSD-like licenses.
+
+See [LICENSE-APACHE](./LICENSE-APACHE), and [LICENSE-MIT](LICENSE-MIT) for details.
diff --git a/vendor/openssl-probe/examples/probe.rs b/vendor/openssl-probe/examples/probe.rs
new file mode 100644
index 000000000..e7a5f5756
--- /dev/null
+++ b/vendor/openssl-probe/examples/probe.rs
@@ -0,0 +1,6 @@
+fn main() {
+ let r = openssl_probe::probe();
+
+ println!("cert_dir: {:?}", r.cert_dir);
+ println!("cert_file: {:?}", r.cert_file);
+}
diff --git a/vendor/openssl-probe/src/lib.rs b/vendor/openssl-probe/src/lib.rs
new file mode 100644
index 000000000..0db12a73f
--- /dev/null
+++ b/vendor/openssl-probe/src/lib.rs
@@ -0,0 +1,136 @@
+use std::env;
+use std::path::{Path, PathBuf};
+
+/// The OpenSSL environment variable to configure what certificate file to use.
+pub const ENV_CERT_FILE: &'static str = "SSL_CERT_FILE";
+
+/// The OpenSSL environment variable to configure what certificates directory to use.
+pub const ENV_CERT_DIR: &'static str = "SSL_CERT_DIR";
+
+pub struct ProbeResult {
+ pub cert_file: Option<PathBuf>,
+ pub cert_dir: Option<PathBuf>,
+}
+
+/// Probe the system for the directory in which CA certificates should likely be
+/// found.
+///
+/// This will only search known system locations.
+pub fn find_certs_dirs() -> Vec<PathBuf> {
+ cert_dirs_iter().map(Path::to_path_buf).collect()
+}
+
+// TODO: when we bump to 0.2, make this the `find_certs_dirs` function
+fn cert_dirs_iter() -> impl Iterator<Item = &'static Path> {
+ // see http://gagravarr.org/writing/openssl-certs/others.shtml
+ [
+ "/var/ssl",
+ "/usr/share/ssl",
+ "/usr/local/ssl",
+ "/usr/local/openssl",
+ "/usr/local/etc/openssl",
+ "/usr/local/share",
+ "/usr/lib/ssl",
+ "/usr/ssl",
+ "/etc/openssl",
+ "/etc/pki/ca-trust/extracted/pem",
+ "/etc/pki/tls",
+ "/etc/ssl",
+ "/etc/certs",
+ "/opt/etc/ssl", // Entware
+ "/data/data/com.termux/files/usr/etc/tls",
+ "/boot/system/data/ssl",
+ ]
+ .iter().map(Path::new).filter(|p| p.exists())
+}
+
+/// Probe for SSL certificates on the system, then configure the SSL certificate `SSL_CERT_FILE`
+/// and `SSL_CERT_DIR` environment variables in this process for OpenSSL to use.
+///
+/// Preconfigured values in the environment variables will not be overwritten if the paths they
+/// point to exist and are accessible.
+pub fn init_ssl_cert_env_vars() {
+ try_init_ssl_cert_env_vars();
+}
+
+/// Probe for SSL certificates on the system, then configure the SSL certificate `SSL_CERT_FILE`
+/// and `SSL_CERT_DIR` environment variables in this process for OpenSSL to use.
+///
+/// Preconfigured values in the environment variables will not be overwritten if the paths they
+/// point to exist and are accessible.
+///
+/// Returns `true` if any certificate file or directory was found while probing.
+/// Combine this with `has_ssl_cert_env_vars()` to check whether previously configured environment
+/// variables are valid.
+pub fn try_init_ssl_cert_env_vars() -> bool {
+ let ProbeResult { cert_file, cert_dir } = probe();
+ // we won't be overwriting existing env variables because if they're valid probe() will have
+ // returned them unchanged
+ if let Some(path) = &cert_file {
+ env::set_var(ENV_CERT_FILE, path);
+ }
+ if let Some(path) = &cert_dir {
+ env::set_var(ENV_CERT_DIR, path);
+ }
+
+ cert_file.is_some() || cert_dir.is_some()
+}
+
+/// Check whether the OpenSSL `SSL_CERT_FILE` and/or `SSL_CERT_DIR` environment variable is
+/// configured in this process with an existing file or directory.
+///
+/// That being the case would indicate that certificates will be found successfully by OpenSSL.
+///
+/// Returns `true` if either variable is set to an existing file or directory.
+pub fn has_ssl_cert_env_vars() -> bool {
+ let probe = probe_from_env();
+ probe.cert_file.is_some() || probe.cert_dir.is_some()
+}
+
+fn probe_from_env() -> ProbeResult {
+ let var = |name| {
+ env::var_os(name)
+ .map(PathBuf::from)
+ .filter(|p| p.exists())
+ };
+ ProbeResult {
+ cert_file: var(ENV_CERT_FILE),
+ cert_dir: var(ENV_CERT_DIR),
+ }
+}
+
+pub fn probe() -> ProbeResult {
+ let mut result = probe_from_env();
+ for certs_dir in cert_dirs_iter() {
+ // cert.pem looks to be an openssl 1.0.1 thing, while
+ // certs/ca-certificates.crt appears to be a 0.9.8 thing
+ let cert_filenames = [
+ "cert.pem",
+ "certs.pem",
+ "ca-bundle.pem",
+ "cacert.pem",
+ "ca-certificates.crt",
+ "certs/ca-certificates.crt",
+ "certs/ca-root-nss.crt",
+ "certs/ca-bundle.crt",
+ "CARootCertificates.pem",
+ "tls-ca-bundle.pem",
+ ];
+ if result.cert_file.is_none() {
+ result.cert_file = cert_filenames
+ .iter()
+ .map(|fname| certs_dir.join(fname))
+ .find(|p| p.exists());
+ }
+ if result.cert_dir.is_none() {
+ let cert_dir = certs_dir.join("certs");
+ if cert_dir.exists() {
+ result.cert_dir = Some(cert_dir);
+ }
+ }
+ if result.cert_file.is_some() && result.cert_dir.is_some() {
+ break;
+ }
+ }
+ result
+}