hyper-rustls-0.24.2/.cargo_vcs_info.json0000644000000001360000000000100136020ustar { "git": { "sha1": "5ab99d99f8749e640f5252adec6cc6e453cc80ac" }, "path_in_vcs": "" }hyper-rustls-0.24.2/.github/dependabot.yml000064400000000000000000000003251046102023000165620ustar 00000000000000version: 2 updates: - package-ecosystem: cargo directory: "/" schedule: interval: daily open-pull-requests-limit: 10 - package-ecosystem: github-actions directory: "/" schedule: interval: weekly hyper-rustls-0.24.2/.github/workflows/build.yml000064400000000000000000000064171046102023000176210ustar 00000000000000name: rustls permissions: contents: read on: push: pull_request: merge_group: schedule: - cron: '23 6 * * 5' jobs: build: name: Build+test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: # test a bunch of toolchains on ubuntu rust: - stable - beta - nightly os: [ubuntu-20.04] # but only stable on macos/windows (slower platforms) include: - os: macos-latest rust: stable - os: windows-latest rust: stable steps: - name: Checkout sources uses: actions/checkout@v4 with: persist-credentials: false - name: Install ${{ matrix.rust }} toolchain uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - name: cargo check (default features) run: cargo check --all-targets - name: cargo test (debug; default features) run: cargo test env: RUST_BACKTRACE: 1 - name: cargo test (debug; native-tokio only) run: cargo test --no-default-features --features native-tokio env: RUST_BACKTRACE: 1 - name: cargo test (debug; webpki-tokio only) run: cargo test --no-default-features --features webpki-tokio env: RUST_BACKTRACE: 1 - name: cargo test (debug; all features) run: cargo test --all-features env: RUST_BACKTRACE: 1 - name: cargo build (debug; no default features) run: cargo build --no-default-features - name: cargo test (debug; no default features; no run) run: cargo test --no-default-features --no-run - name: cargo test (release; no run) run: cargo test --release --no-run msrv: runs-on: ubuntu-20.04 steps: - name: Checkout sources uses: actions/checkout@v4 with: persist-credentials: false - name: Install rust toolchain uses: dtolnay/rust-toolchain@master with: toolchain: "1.63" - name: Check MSRV run: cargo check --lib --all-features docs: name: Check for documentation errors runs-on: ubuntu-20.04 steps: - name: Checkout sources uses: actions/checkout@v4 with: persist-credentials: false - name: Install rust toolchain uses: dtolnay/rust-toolchain@nightly - name: cargo doc (all features) run: cargo doc --all-features --no-deps env: RUSTDOCFLAGS: -Dwarnings format: name: Format runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v4 with: persist-credentials: false - name: Install rust toolchain uses: dtolnay/rust-toolchain@stable with: components: rustfmt - name: Check formatting run: cargo fmt --all -- --check clippy: name: Clippy runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v4 with: persist-credentials: false - name: Install rust toolchain uses: dtolnay/rust-toolchain@stable with: components: clippy - run: cargo clippy --all-features -- --deny warnings hyper-rustls-0.24.2/.gitignore000064400000000000000000000000231046102023000143550ustar 00000000000000Cargo.lock target/ hyper-rustls-0.24.2/.rustfmt.toml000064400000000000000000000000171046102023000150470ustar 00000000000000chain_width=40 hyper-rustls-0.24.2/Cargo.lock0000644000000450360000000000100115650ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", ] [[package]] name = "base64" version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bytes" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "core-foundation" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", ] [[package]] name = "core-foundation-sys" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "futures-channel" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-sink" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", "futures-task", "pin-project-lite", "pin-utils", ] [[package]] name = "getrandom" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "gimli" version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "h2" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", "futures-core", "futures-sink", "futures-util", "http", "indexmap", "slab", "tokio", "tokio-util", "tracing", ] [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hermit-abi" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "http" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", "itoa", ] [[package]] name = "http-body" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", "pin-project-lite", ] [[package]] name = "httparse" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", "h2", "http", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", "socket2 0.4.10", "tokio", "tower-service", "tracing", "want", ] [[package]] name = "hyper-rustls" version = "0.24.2" dependencies = [ "futures-util", "http", "hyper", "log", "rustls", "rustls-native-certs", "rustls-pemfile", "tokio", "tokio-rustls", "webpki-roots", ] [[package]] name = "indexmap" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", ] [[package]] name = "itoa" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "libc" version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "miniz_oxide" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "mio" version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", "windows-sys", ] [[package]] name = "num_cpus" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ "hermit-abi", "libc", ] [[package]] name = "object" version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] [[package]] name = "ring" version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", "getrandom", "libc", "spin", "untrusted", "windows-sys", ] [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustls" version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", "ring", "rustls-webpki", "sct", ] [[package]] name = "rustls-native-certs" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", "schannel", "security-framework", ] [[package]] name = "rustls-pemfile" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ "base64", ] [[package]] name = "rustls-webpki" version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", ] [[package]] name = "schannel" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ "windows-sys", ] [[package]] name = "sct" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", ] [[package]] name = "security-framework" version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ "bitflags", "core-foundation", "core-foundation-sys", "libc", "security-framework-sys", ] [[package]] name = "security-framework-sys" version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", ] [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "socket2" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", ] [[package]] name = "socket2" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys", ] [[package]] name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "syn" version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "tokio" version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", "libc", "mio", "num_cpus", "pin-project-lite", "socket2 0.5.5", "tokio-macros", "windows-sys", ] [[package]] name = "tokio-macros" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tokio-rustls" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ "rustls", "tokio", ] [[package]] name = "tokio-util" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", "tracing", ] [[package]] name = "tower-service" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "try-lock" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "untrusted" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "want" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ "try-lock", ] [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "webpki-roots" version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" hyper-rustls-0.24.2/Cargo.toml0000644000000047530000000000100116110ustar # 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] edition = "2021" rust-version = "1.63" name = "hyper-rustls" version = "0.24.2" description = "Rustls+hyper integration for pure rust HTTPS" homepage = "https://github.com/rustls/hyper-rustls" documentation = "https://docs.rs/hyper-rustls/" readme = "README.md" license = "Apache-2.0 OR ISC OR MIT" repository = "https://github.com/rustls/hyper-rustls" [package.metadata.docs.rs] all-features = true rustdoc-args = [ "--cfg", "docsrs", ] [[example]] name = "client" path = "examples/client.rs" required-features = [ "native-tokio", "http1", ] [[example]] name = "server" path = "examples/server.rs" required-features = [ "tokio-runtime", "acceptor", ] [dependencies.futures-util] version = "0.3" default-features = false [dependencies.http] version = "0.2" [dependencies.hyper] version = "0.14" features = ["client"] default-features = false [dependencies.log] version = "0.4.4" optional = true [dependencies.rustls] version = "0.21.6" default-features = false [dependencies.rustls-native-certs] version = "0.6" optional = true [dependencies.tokio] version = "1.0" [dependencies.tokio-rustls] version = "0.24.0" default-features = false [dependencies.webpki-roots] version = "0.25" optional = true [dev-dependencies.hyper] version = "0.14" features = ["full"] [dev-dependencies.rustls] version = "0.21.0" features = ["tls12"] default-features = false [dev-dependencies.rustls-pemfile] version = "1.0.0" [dev-dependencies.tokio] version = "1.0" features = [ "io-std", "macros", "net", "rt-multi-thread", ] [features] acceptor = [ "hyper/server", "tokio-runtime", ] default = [ "native-tokio", "http1", "tls12", "logging", "acceptor", ] http1 = ["hyper/http1"] http2 = ["hyper/http2"] logging = [ "log", "tokio-rustls/logging", "rustls/logging", ] native-tokio = [ "tokio-runtime", "rustls-native-certs", ] tls12 = [ "tokio-rustls/tls12", "rustls/tls12", ] tokio-runtime = ["hyper/runtime"] webpki-tokio = [ "tokio-runtime", "webpki-roots", ] hyper-rustls-0.24.2/Cargo.toml.orig000064400000000000000000000034071046102023000152650ustar 00000000000000[package] name = "hyper-rustls" version = "0.24.2" edition = "2021" rust-version = "1.63" license = "Apache-2.0 OR ISC OR MIT" readme = "README.md" description = "Rustls+hyper integration for pure rust HTTPS" homepage = "https://github.com/rustls/hyper-rustls" repository = "https://github.com/rustls/hyper-rustls" documentation = "https://docs.rs/hyper-rustls/" [dependencies] http = "0.2" hyper = { version = "0.14", default-features = false, features = ["client"] } log = { version = "0.4.4", optional = true } rustls-native-certs = { version = "0.6", optional = true } rustls = { version = "0.21.6", default-features = false } tokio = "1.0" tokio-rustls = { version = "0.24.0", default-features = false } webpki-roots = { version = "0.25", optional = true } futures-util = { version = "0.3", default-features = false } [dev-dependencies] hyper = { version = "0.14", features = ["full"] } rustls = { version = "0.21.0", default-features = false, features = ["tls12"] } rustls-pemfile = "1.0.0" tokio = { version = "1.0", features = ["io-std", "macros", "net", "rt-multi-thread"] } [features] default = ["native-tokio", "http1", "tls12", "logging", "acceptor"] acceptor = ["hyper/server", "tokio-runtime"] http1 = ["hyper/http1"] http2 = ["hyper/http2"] webpki-tokio = ["tokio-runtime", "webpki-roots"] native-tokio = ["tokio-runtime", "rustls-native-certs"] tokio-runtime = ["hyper/runtime"] tls12 = ["tokio-rustls/tls12", "rustls/tls12"] logging = ["log", "tokio-rustls/logging", "rustls/logging"] [[example]] name = "client" path = "examples/client.rs" required-features = ["native-tokio", "http1"] [[example]] name = "server" path = "examples/server.rs" required-features = ["tokio-runtime", "acceptor"] [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] hyper-rustls-0.24.2/LICENSE000064400000000000000000000004441046102023000134010ustar 00000000000000hyper-rustls is distributed under the following three licenses: - Apache License version 2.0. - MIT license. - ISC license. These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC respectively. You may use this software under the terms of any of these licenses, at your option. hyper-rustls-0.24.2/LICENSE-APACHE000064400000000000000000000251371046102023000143260ustar 00000000000000 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. hyper-rustls-0.24.2/LICENSE-ISC000064400000000000000000000014071046102023000140150ustar 00000000000000ISC License (ISC) Copyright (c) 2016, Joseph Birr-Pixton 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. hyper-rustls-0.24.2/LICENSE-MIT000064400000000000000000000020721046102023000140270ustar 00000000000000Copyright (c) 2016 Joseph Birr-Pixton 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. hyper-rustls-0.24.2/README.md000064400000000000000000000021001046102023000136420ustar 00000000000000# hyper-rustls This is an integration between the [rustls TLS stack](https://github.com/rustls/rustls) and the [hyper HTTP library](https://github.com/hyperium/hyper). [![Build Status](https://github.com/rustls/hyper-rustls/workflows/hyper-rustls/badge.svg)](https://github.com/rustls/hyper-rustls/actions) [![Crate](https://img.shields.io/crates/v/hyper-rustls.svg)](https://crates.io/crates/hyper-rustls) [![Documentation](https://docs.rs/hyper-rustls/badge.svg)](https://docs.rs/hyper-rustls/) # Release history Release history can be found [on GitHub](https://github.com/rustls/hyper-rustls/releases). # License hyper-rustls is distributed under the following three licenses: - Apache License version 2.0. - MIT license. - ISC license. These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC respectively. You may use this software under the terms of any of these licenses, at your option. ## Running examples ### server ```bash cargo run --example server ``` ### client ```bash cargo run --example client "https://docs.rs/hyper-rustls/latest/hyper_rustls/" ``` hyper-rustls-0.24.2/RELEASING.md000064400000000000000000000026561046102023000142360ustar 00000000000000# Making a hyper-rustls release This is a checklist for steps to make before/after making a rustls release. 1. Attend to the README.md: this appears on crates.io for the release, and can't be edited after the fact. - Ensure the version has a good set of release notes. Move old release notes to OLDCHANGES.md if this is getting excessively long. - Write the version and date of the release. 2. Run `cargo update` followed by `cargo outdated`, to check if we have any dependency updates which are not already automatically taken by their semver specs. - If we do, take them if possible with separate commits (but there should've been dependabot PRs submitted for these already.) 3. Now run `cargo test --all-features` to ensure our tests continue to pass with the updated dependencies. 4. Update `Cargo.toml` to set the correct version. 5. Make a commit with the above changes, something like 'Prepare $VERSION'. This should not contain functional changes: just versions numbers, and markdown changes. 6. Do a dry run: check `cargo publish --dry-run` 7. Push the above commit. Wait for CI to confirm it as green. - Any red _should_ naturally block the release. - If rustc nightly is broken, this _may_ be acceptable if the reason is understood and does not point to a defect. 8. Tag the released version: `git tag -m '0.20.0' v/0.20.0` 9. Push the tag: `git push --tags` 10. Do the release: `cargo publish`. hyper-rustls-0.24.2/examples/client.rs000064400000000000000000000061611046102023000160400ustar 00000000000000//! Simple HTTPS GET client based on hyper-rustls //! //! First parameter is the mandatory URL to GET. //! Second parameter is an optional path to CA store. use hyper::{body::to_bytes, client, Body, Uri}; use hyper_rustls::ConfigBuilderExt; use rustls::RootCertStore; use std::str::FromStr; use std::{env, fs, io}; fn main() { // Send GET request and inspect result, with proper error handling. if let Err(e) = run_client() { eprintln!("FAILED: {}", e); std::process::exit(1); } } fn error(err: String) -> io::Error { io::Error::new(io::ErrorKind::Other, err) } #[tokio::main] async fn run_client() -> io::Result<()> { // First parameter is target URL (mandatory). let url = match env::args().nth(1) { Some(ref url) => Uri::from_str(url).map_err(|e| error(format!("{}", e)))?, None => { println!("Usage: client "); return Ok(()); } }; // Second parameter is custom Root-CA store (optional, defaults to native cert store). let mut ca = match env::args().nth(2) { Some(ref path) => { let f = fs::File::open(path) .map_err(|e| error(format!("failed to open {}: {}", path, e)))?; let rd = io::BufReader::new(f); Some(rd) } None => None, }; // Prepare the TLS client config let tls = match ca { Some(ref mut rd) => { // Read trust roots let certs = rustls_pemfile::certs(rd) .map_err(|_| error("failed to load custom CA store".into()))?; let mut roots = RootCertStore::empty(); roots.add_parsable_certificates(&certs); // TLS client config using the custom CA store for lookups rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(roots) .with_no_client_auth() } // Default TLS client config with native roots None => rustls::ClientConfig::builder() .with_safe_defaults() .with_native_roots() .with_no_client_auth(), }; // Prepare the HTTPS connector let https = hyper_rustls::HttpsConnectorBuilder::new() .with_tls_config(tls) .https_or_http() .enable_http1() .build(); // Build the hyper client from the HTTPS connector. let client: client::Client<_, hyper::Body> = client::Client::builder().build(https); // Prepare a chain of futures which sends a GET request, inspects // the returned headers, collects the whole body and prints it to // stdout. let fut = async move { let res = client .get(url) .await .map_err(|e| error(format!("Could not get: {:?}", e)))?; println!("Status:\n{}", res.status()); println!("Headers:\n{:#?}", res.headers()); let body: Body = res.into_body(); let body = to_bytes(body) .await .map_err(|e| error(format!("Could not get body: {:?}", e)))?; println!("Body:\n{}", String::from_utf8_lossy(&body)); Ok(()) }; fut.await } hyper-rustls-0.24.2/examples/openssl.cnf000064400000000000000000000013711046102023000163650ustar 00000000000000 [ v3_end ] basicConstraints = critical,CA:false keyUsage = nonRepudiation, digitalSignature subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer:always subjectAltName = @alt_names [ v3_client ] basicConstraints = critical,CA:false keyUsage = nonRepudiation, digitalSignature extendedKeyUsage = critical, clientAuth subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer:always [ v3_inter ] subjectKeyIdentifier = hash extendedKeyUsage = critical, serverAuth, clientAuth basicConstraints = CA:true keyUsage = cRLSign, keyCertSign, digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign [ alt_names ] DNS.1 = testserver.com DNS.2 = second.testserver.com DNS.3 = localhost hyper-rustls-0.24.2/examples/refresh-certificates.sh000075500000000000000000000024041046102023000206500ustar 00000000000000#!/bin/sh set -xe openssl req -nodes \ -x509 \ -days 3650 \ -newkey rsa:4096 \ -keyout ca.key \ -out ca.cert \ -sha256 \ -batch \ -subj "/CN=ponytown RSA CA" openssl req -nodes \ -newkey rsa:3072 \ -keyout inter.key \ -out inter.req \ -sha256 \ -batch \ -subj "/CN=ponytown RSA level 2 intermediate" openssl req -nodes \ -newkey rsa:2048 \ -keyout end.key \ -out end.req \ -sha256 \ -batch \ -subj "/CN=testserver.com" openssl rsa \ -in end.key \ -out sample.rsa openssl x509 -req \ -in inter.req \ -out inter.cert \ -CA ca.cert \ -CAkey ca.key \ -sha256 \ -days 3650 \ -set_serial 123 \ -extensions v3_inter -extfile openssl.cnf openssl x509 -req \ -in end.req \ -out end.cert \ -CA inter.cert \ -CAkey inter.key \ -sha256 \ -days 2000 \ -set_serial 456 \ -extensions v3_end -extfile openssl.cnf cat end.cert inter.cert ca.cert > sample.pem rm *.key *.cert *.req hyper-rustls-0.24.2/examples/sample.pem000064400000000000000000000112771046102023000162040ustar 00000000000000-----BEGIN CERTIFICATE----- MIIEADCCAmigAwIBAgICAcgwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UEAwwhcG9u eXRvd24gUlNBIGxldmVsIDIgaW50ZXJtZWRpYXRlMB4XDTIyMDcwNDE0MzA1OFoX DTI3MTIyNTE0MzA1OFowGTEXMBUGA1UEAwwOdGVzdHNlcnZlci5jb20wggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDL35qLQLIqswCmHJxyczYF2p0YxXCq gMvtRcKVElnifPMFrbGCY1aYBmhIiXPGRwhfythAtYfDQsrXFADZd52JPgZCR/u6 DQMqKD2lcvFQkf7Kee/fNTOuQTQPh1XQx4ntxvicSATwEnuU28NwVnOU//Zzq2xn Q34gUQNHWp1pN+B1La7emm/Ucgs1/2hMxwCZYUnRoiUoRGXUSzZuWokDOstPNkjc +AjHmxONgowogmL2jKN9BjBw/8psGoqEOjMO+Lb9iekOCzX4kqHaRUbTlbSAviQu 2Q115xiZCBCZVtNE6DUG25buvpMSEXwpLd96nLywbrSCyueC7cd01/hpAgMBAAGj gb4wgbswDAYDVR0TAQH/BAIwADALBgNVHQ8EBAMCBsAwHQYDVR0OBBYEFHGnzC5Q A62Wmv4zfMk/kf/BxHevMEIGA1UdIwQ7MDmAFDMRUvwxXbYDBCxOdQ9xfBnNWUz0 oR6kHDAaMRgwFgYDVQQDDA9wb255dG93biBSU0EgQ0GCAXswOwYDVR0RBDQwMoIO dGVzdHNlcnZlci5jb22CFXNlY29uZC50ZXN0c2VydmVyLmNvbYIJbG9jYWxob3N0 MA0GCSqGSIb3DQEBCwUAA4IBgQBqKNIM/JBGRmGEopm5/WNKV8UoxKPA+2jR020t RumXMAnJEfhsivF+Zw/rDmSDpmts/3cIlesKi47f13q4Mfj1QytQUDrsuQEyRTrV Go6BOQQ4dkS+IqnIfSuue70wpvrZHhRHNFdFt9qM5wCLQokXlP988sEWUmyPPCbO 1BEpwWcP1kx+PdY8NKOhMnfq2RfluI/m4MA4NxJqAWajAhIbDNbvP8Ov4a71HPa6 b1q9qIQE1ut8KycTrm9K32bVbvMHvR/TPUue8W0VvV2rWTGol5TSNgEQb9w6Kyf7 N5HlRl9kZB4K8ckWH/JVn0pYNBQPgwbcUbJ/jp6w+LHrh+UW75maOY+IGjVICud8 6Rc5DZZ2+AAbXJQZ1HMPrw9SW/16Eh/A4CIEsvbu9J+7IoSzhgcKFzOCUojzzRSj iU7w/HsvpltmVCAZcZ/VARFbe1By2wXX2GSw2p2FVC8orXs76QyruPAVgSHCTVes zzBo6GLScO/3b6uAcPM3MHRGGvE= -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIEnzCCAoegAwIBAgIBezANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDDA9wb255 dG93biBSU0EgQ0EwHhcNMjIwNzA0MTQzMDU4WhcNMzIwNzAxMTQzMDU4WjAsMSow KAYDVQQDDCFwb255dG93biBSU0EgbGV2ZWwgMiBpbnRlcm1lZGlhdGUwggGiMA0G CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCsTkd2SKiy3yy20lygOhKfOySo3qpq TZVrpW11vQ58+6EcetXRnzIIK0HyhPmZrv9XKPpQclJvfY9jADNtu2CSj/v15OSB Love3GzmXSZz2A8QUZBPWx6HczDG1hFGzrCZPKzpeLnFD1LPsKCUkUOHl1acyy24 DaCacQJPzPQWbMhbGmYRlDNb+2R2K6UKMAEVe4IOTv2aSIKDGLI+xlaBXYAJj48L //9eNmR3bMP3kkNKOKaaBk8vnYxKpZ+8ZHeHTmYWR9x1ZoMcbA9lKUwRpKAjY5JJ NVZMDmjlVQVvvBrvhgz/zgXtfuaQCryZ0f1sEY/zXhdealo3fGVomeoniD4XwA1c oaUFkbo5IM5HU/pXyAGRerDyhYLgRqQZMIRauvKRPN3jLsPOEQ0+gnXUUTr/YGIE KY3/Axg4P3hzZCFqJ5IgkgWZr/dKr9p/0cxSUGHTVcpEFOlkKIIIdRuR7Ng5sJml u7PAMWt6T+x02ORs1/WkyP7LyPQmuugYTicCAwEAAaNeMFwwHQYDVR0OBBYEFDMR UvwxXbYDBCxOdQ9xfBnNWUz0MCAGA1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEF BQcDAjAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB/jANBgkqhkiG9w0BAQsFAAOC AgEAYzqmX+cNPgVD2HWgbeimUraTpI9JP5P4TbOHWmaJKecoy3Hwr71xyAOGiVXL urk1ZZe8n++GwuDEgRajN3HO9LR1Pu9qVIzTYIsz0ORRQHxujnF7CxK/I/vrIgde pddUdHNS0Y0g8J1emH9BgoD8a2YsGX4iDY4S4hIGBbGvQp9z8U/uG1mViAmlXybM b8bf0dx0tEFUyu8jsQP6nFLY/HhkEcvU6SnOzZHRsFko6NE44VIsHLd2+LS2LCM/ NfAoTzgvj41M3zQCZapaHZc9KXfdcCvEFaySKGfEZeQTUR5W0FHsF5I4NLGryf5L h3ENQ1tgBTO5WnqL/5rbgv6va9VionPM5sbEwAcancejnkVs3NoYPIPPgBFjaFmL hNTpT9H2owdZvEwNDChVS0b8ukNNd4cERtvy0Ohc3mk0LGN0ABzrud0fIqa51LMh 0N3dkPkiZ4XYk4yLJ5EwCrCNNH50QkGCOWpInKIPeSYcALGgBDbCDLv6rV3oSKrV tHCZQwXVKKgU4AQu7hlHBwJ61cH44ksydOidW3MNq1kDIp7ST8s7gVrItNgFnG+L Jpo270riwSUlWDY4hXw5Ff5lE+bWCmFyyOkLevDkD9v8M4HdwEVvafYYwn75fCIS 5OnpSeIB08kKqCtW1WBwki0rYJjWqdzI7Z1MQ/AyScAKiGM= -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIEsDCCApgCCQCfkxy3a+AgNjANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDDA9w b255dG93biBSU0EgQ0EwHhcNMjIwNzA0MTQzMDU3WhcNMzIwNzAxMTQzMDU3WjAa MRgwFgYDVQQDDA9wb255dG93biBSU0EgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC DwAwggIKAoICAQCj6nW8pnN50UsH2NjL97xZKxlXPe5ptXfvqXczMsw0vB3gI4xJ Tdmrnqo0K+VOH7vh+UXcOj2ZMY2ou6oDDK5Qpu9bvGPBIJH/rC1Ti2+u5Y4KTIUc jWAtzQJeFn8+oCMfskpLdtlWLRdAuwqNHjvxXdd2JnsX1Wid85U/rG2SNPLGjJAF xG7xzZC4VSO2WIXTGRMUkZfFc8fhWMjo3GaeF/qYjzfHDPWN/ll/7vfxyXJO/ohw FzpJSZtKmI+6PLxqB/oFrKfTDQUGzxjfHp187bI3eyUFMJsp18/tLYkLyxSWIg3o bq7ZVimHd1UG2Vb5Y+5pZkh22jmJ6bAa/kmNNwbsD+5vJhW1myGhmZSxkreYPWnS 6ELrSMvbXccFfTYmdBlWsZx/zUVUzVCPe9jdJki2VXlicohqtvBQqe6LGGO37vvv Gwu1yzQ/rJy47rnaao7fSxqM8nsDjNR2Ev1v031QpEMWjfgUW0roW3H58RZSx+kU gzIS2CjJIqKxCp894FUQbC6r0wwAuKltl3ywz5qWkxY0O9bXS0YdEXiri5pdsWjr 84shVVQwnoVD9539CLSdHZjlOCAzvSWHZH6ta2JZjUfYYz8cLyv2c2+y9BYrlvHw T7U7BqzngUk72gcRXd5+Onp+16gGxpGJqaxqj94Nh/yTUnr2Jd9YaXeFmQIDAQAB MA0GCSqGSIb3DQEBCwUAA4ICAQBzIRVRt3Yaw60tpkyz/i1xbKCbtC+HqYTEsXvZ RvZ5X1qyLAcmu4EW9RHXnlLiawDbES6lCMFfdBUK03Wis7socvoFUCBRW337F4z2 IivHfIge4u+w5ouUKPzcpj6oeuR06tmNytYbno6l8tXJpm1eeO4KNZ0ZtodmyB5D yLrplFgxTdGGgyvxt8LoeLwGmPCyVt35x/Mz6x2lcq1+r7QJZ9sENhQYuA8UqHrw fmNoVIMXMEcPLcWtFl6nKTK9LrqAu1jgTBqGGZKRn5CYBBK3pNEGKiOIsZXDbyFS F59teFpJjyeJTbUbLxXDa15J6ExkHV9wFLEvfu/nzQzg8D9yzczSdbDkE2rrrL+s Q/H/pIXO/DesCWQ37VALn3B5gm9UBd5uogbSw8eamiwRFLQ0snP80pJQGJoTNn0P wrLLUf2gsKC2262igiA+imepm5wxbV9XGVZfHJgxCi5Zqrf6aWnjIqD2YtDvAHhs V8ZWN3QTjdnEcQbG0544rocoLNX/FzmyDgjfZKY5r6wt+FWNc/R4clkF+KxasxqB HdBs8j0lGV3ujvNXASLq9HI6VxZayrSfkR73hADCXIM/wzynKwMarvA4SXwYX9Pd cJ4+FMqrevPpamMHUsNndS0KfDTdjDp+TSBf87yiyRkD1Ri4ePslyfNvRyv3Xs7k 47YFzA== -----END CERTIFICATE----- hyper-rustls-0.24.2/examples/sample.rsa000064400000000000000000000032171046102023000162030ustar 00000000000000-----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAy9+ai0CyKrMAphyccnM2BdqdGMVwqoDL7UXClRJZ4nzzBa2x gmNWmAZoSIlzxkcIX8rYQLWHw0LK1xQA2XediT4GQkf7ug0DKig9pXLxUJH+ynnv 3zUzrkE0D4dV0MeJ7cb4nEgE8BJ7lNvDcFZzlP/2c6tsZ0N+IFEDR1qdaTfgdS2u 3ppv1HILNf9oTMcAmWFJ0aIlKERl1Es2blqJAzrLTzZI3PgIx5sTjYKMKIJi9oyj fQYwcP/KbBqKhDozDvi2/YnpDgs1+JKh2kVG05W0gL4kLtkNdecYmQgQmVbTROg1 BtuW7r6TEhF8KS3fepy8sG60gsrngu3HdNf4aQIDAQABAoIBAFTehqVFj2W7EqAT 9QSn9WtGcHNpbddsunfRvIj2FLj2LuzEO8r9s4Sh1jOsFKgL1e6asJ9vck7UtUAH sbrV0pzZVx2sfZwb4p9gFRmU2eQigqCjVjnjGdqGhjeYrR62kjKLy96zFGskJpH3 UkqnkoIKc/v+9qeeLxkg4G6JyFGOFHJAZEraxoGydJk9n/yBEZ/+3W7JUJaGOUNU M7BYsCS2VOJr+cCqmCk1j8NvYvWWxTPsIXgGJl4EOoskzlzJnYLdh9fPFZu3uOIx hpm3DBNp6X+qXf1lmx9EdpyeXKpLFIgJM7+nw2uWzxW7XMlRERi+5Tprc/pjrqUq gpfyvMkCgYEA909QcJpS3qHoWyxGbI1zosVIZXdnj8L+GF/2kEQEU5iEYT+2M1U+ gCPLr49gNwkD1FdBSCy+Fw20zi35jGmxNwhgp4V94CGYzqwQzpnvgIRBMiAIoEwI CD5/t34DZ/82u8Gb7UYVrzOD54rJ628Q+tJEJak3TqoShbvcxJC/rXMCgYEA0wmO SRoxrBE3rFzNQkqHbMHLe9LksW9YSIXdMBjq4DhzQEwI0YgPLajXnsLurqHaJrQA JPtYkqiJkV7rvJLBo5wxwU+O2JKKa2jcMwuCZ4hOg5oBfK6ES9QJZUL7kDe2vsWy rL+rnxJheUjDPBTopGHuuc9Nogid35CE0wy7S7MCgYArxB+KLeVofOKv79/uqgHC 1oL/Yegz6uAo1CLAWSki2iTjSPEnmHhdGPic8xSl6LSCyYZGDZT+Y3CR5FT7YmD4 SkVAoEEsfwWZ3Z2D0n4uEjmvczfTlmD9hIH5qRVVPDcldxfvH64KuWUofslJHvi0 Sq3AtHeTNknc3Ogu6SbivQKBgQC4ZAsMWHS6MTkBwvwdRd1Z62INyNDFL9JlW4FN uxfN3cTlkwnJeiY48OOk9hFySDzBwFi3910Gl3fLqrIyy8+hUqIuk4LuO+vxuWdc uluwdmqTlgZimGFDl/q1nXcMJYHo4fgh9D7R+E9ul2Luph43MtJRS447W2gFpNJJ TUCA/QKBgQC07GFP2BN74UvL12f+FpZvE/UFtWnSZ8yJSq8oYpIbhmoF5EUF+XdA E2y3l1cvmDJFo4RNZl+IQIbHACR3y1XOnh4/B9fMEsVQHK3x8exPk1vAk687bBG8 TVDmdP52XEKHplcVoYKvGzw/wsObLAGyIbJ00t1VPU+7guTPsc+H/w== -----END RSA PRIVATE KEY----- hyper-rustls-0.24.2/examples/server.rs000064400000000000000000000072721046102023000160740ustar 00000000000000//! Simple HTTPS echo service based on hyper-rustls //! //! First parameter is the mandatory port to use. //! Certificate and private key are hardcoded to sample files. //! hyper will automatically use HTTP/2 if a client starts talking HTTP/2, //! otherwise HTTP/1.1 will be used. #![cfg(feature = "acceptor")] use std::vec::Vec; use std::{env, fs, io}; use hyper::server::conn::AddrIncoming; use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Method, Request, Response, Server, StatusCode}; use hyper_rustls::TlsAcceptor; fn main() { // Serve an echo service over HTTPS, with proper error handling. if let Err(e) = run_server() { eprintln!("FAILED: {}", e); std::process::exit(1); } } fn error(err: String) -> io::Error { io::Error::new(io::ErrorKind::Other, err) } #[tokio::main] async fn run_server() -> Result<(), Box> { // First parameter is port number (optional, defaults to 1337) let port = match env::args().nth(1) { Some(ref p) => p.to_owned(), None => "1337".to_owned(), }; let addr = format!("127.0.0.1:{}", port).parse()?; // Load public certificate. let certs = load_certs("examples/sample.pem")?; // Load private key. let key = load_private_key("examples/sample.rsa")?; // Build TLS configuration. // Create a TCP listener via tokio. let incoming = AddrIncoming::bind(&addr)?; let acceptor = TlsAcceptor::builder() .with_single_cert(certs, key) .map_err(|e| error(format!("{}", e)))? .with_all_versions_alpn() .with_incoming(incoming); let service = make_service_fn(|_| async { Ok::<_, io::Error>(service_fn(echo)) }); let server = Server::builder(acceptor).serve(service); // Run the future, keep going until an error occurs. println!("Starting to serve on https://{}.", addr); server.await?; Ok(()) } // Custom echo service, handling two different routes and a // catch-all 404 responder. async fn echo(req: Request) -> Result, hyper::Error> { let mut response = Response::new(Body::empty()); match (req.method(), req.uri().path()) { // Help route. (&Method::GET, "/") => { *response.body_mut() = Body::from("Try POST /echo\n"); } // Echo service route. (&Method::POST, "/echo") => { *response.body_mut() = req.into_body(); } // Catch-all 404. _ => { *response.status_mut() = StatusCode::NOT_FOUND; } }; Ok(response) } // Load public certificate from file. fn load_certs(filename: &str) -> io::Result> { // Open certificate file. let certfile = fs::File::open(filename) .map_err(|e| error(format!("failed to open {}: {}", filename, e)))?; let mut reader = io::BufReader::new(certfile); // Load and return certificate. let certs = rustls_pemfile::certs(&mut reader) .map_err(|_| error("failed to load certificate".into()))?; Ok(certs .into_iter() .map(rustls::Certificate) .collect()) } // Load private key from file. fn load_private_key(filename: &str) -> io::Result { // Open keyfile. let keyfile = fs::File::open(filename) .map_err(|e| error(format!("failed to open {}: {}", filename, e)))?; let mut reader = io::BufReader::new(keyfile); // Load and return a single private key. let keys = rustls_pemfile::rsa_private_keys(&mut reader) .map_err(|_| error("failed to load private key".into()))?; if keys.len() != 1 { return Err(error("expected a single private key".into())); } Ok(rustls::PrivateKey(keys[0].clone())) } hyper-rustls-0.24.2/src/acceptor/builder.rs000064400000000000000000000067651046102023000167730ustar 00000000000000use std::sync::Arc; use hyper::server::conn::AddrIncoming; use rustls::ServerConfig; use super::TlsAcceptor; /// Builder for [`TlsAcceptor`] pub struct AcceptorBuilder(State); /// State of a builder that needs a TLS client config next pub struct WantsTlsConfig(()); impl AcceptorBuilder { /// Creates a new [`AcceptorBuilder`] pub fn new() -> Self { Self(WantsTlsConfig(())) } /// Passes a rustls [`ServerConfig`] to configure the TLS connection pub fn with_tls_config(self, config: ServerConfig) -> AcceptorBuilder { AcceptorBuilder(WantsAlpn(config)) } /// Use rustls [defaults][with_safe_defaults] without [client authentication][with_no_client_auth] /// /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults /// [with_no_client_auth]: rustls::ConfigBuilder::with_no_client_auth pub fn with_single_cert( self, cert_chain: Vec, key_der: rustls::PrivateKey, ) -> Result, rustls::Error> { Ok(AcceptorBuilder(WantsAlpn( ServerConfig::builder() .with_safe_defaults() .with_no_client_auth() .with_single_cert(cert_chain, key_der)?, ))) } } impl Default for AcceptorBuilder { fn default() -> Self { Self::new() } } /// State of a builder that needs a incoming address next pub struct WantsAlpn(ServerConfig); impl AcceptorBuilder { /// Configure ALPN accept protocols in order pub fn with_alpn_protocols( mut self, alpn_protocols: Vec>, ) -> AcceptorBuilder { self.0 .0.alpn_protocols = alpn_protocols; AcceptorBuilder(WantsIncoming(self.0 .0)) } /// Configure ALPN to accept HTTP/2 pub fn with_http2_alpn(mut self) -> AcceptorBuilder { self.0 .0.alpn_protocols = vec![b"h2".to_vec()]; AcceptorBuilder(WantsIncoming(self.0 .0)) } /// Configure ALPN to accept HTTP/1.0 pub fn with_http10_alpn(mut self) -> AcceptorBuilder { self.0 .0.alpn_protocols = vec![b"http/1.0".to_vec()]; AcceptorBuilder(WantsIncoming(self.0 .0)) } /// Configure ALPN to accept HTTP/1.1 pub fn with_http11_alpn(mut self) -> AcceptorBuilder { self.0 .0.alpn_protocols = vec![b"http/1.1".to_vec()]; AcceptorBuilder(WantsIncoming(self.0 .0)) } /// Configure ALPN to accept HTTP/2, HTTP/1.1, HTTP/1.0 in that order. pub fn with_all_versions_alpn(mut self) -> AcceptorBuilder { self.0 .0.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec(), b"http/1.0".to_vec()]; AcceptorBuilder(WantsIncoming(self.0 .0)) } } /// State of a builder that needs a incoming address next pub struct WantsIncoming(ServerConfig); impl AcceptorBuilder { /// Passes a [`AddrIncoming`] to configure the TLS connection and /// creates the [`TlsAcceptor`] pub fn with_incoming(self, incoming: impl Into) -> TlsAcceptor { self.with_acceptor(incoming.into()) } /// Passes an acceptor implementing [`Accept`] to configure the TLS connection and /// creates the [`TlsAcceptor`] /// /// [`Accept`]: hyper::server::accept::Accept pub fn with_acceptor(self, acceptor: A) -> TlsAcceptor { TlsAcceptor { config: Arc::new(self.0 .0), acceptor, } } } hyper-rustls-0.24.2/src/acceptor.rs000064400000000000000000000122551046102023000153340ustar 00000000000000use core::task::{Context, Poll}; use std::future::Future; use std::io; use std::pin::Pin; use std::sync::Arc; use futures_util::ready; use hyper::server::{ accept::Accept, conn::{AddrIncoming, AddrStream}, }; use rustls::{ServerConfig, ServerConnection}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; mod builder; pub use builder::AcceptorBuilder; use builder::WantsTlsConfig; /// A TLS acceptor that can be used with hyper servers. pub struct TlsAcceptor { config: Arc, acceptor: A, } /// An Acceptor for the `https` scheme. impl TlsAcceptor { /// Provides a builder for a `TlsAcceptor`. pub fn builder() -> AcceptorBuilder { AcceptorBuilder::new() } /// Creates a new `TlsAcceptor` from a `ServerConfig` and an `AddrIncoming`. pub fn new(config: Arc, incoming: AddrIncoming) -> Self { Self { config, acceptor: incoming, } } } impl Accept for TlsAcceptor where A: Accept + Unpin, A::Conn: AsyncRead + AsyncWrite + Unpin, { type Conn = TlsStream; type Error = io::Error; fn poll_accept( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll>> { let pin = self.get_mut(); Poll::Ready(match ready!(Pin::new(&mut pin.acceptor).poll_accept(cx)) { Some(Ok(sock)) => Some(Ok(TlsStream::new(sock, pin.config.clone()))), Some(Err(e)) => Some(Err(e)), None => None, }) } } impl From<(C, I)> for TlsAcceptor where C: Into>, I: Into, { fn from((config, incoming): (C, I)) -> Self { Self::new(config.into(), incoming.into()) } } /// A TLS stream constructed by a [`TlsAcceptor`]. // tokio_rustls::server::TlsStream doesn't expose constructor methods, // so we have to TlsAcceptor::accept and handshake to have access to it // TlsStream implements AsyncRead/AsyncWrite by handshaking with tokio_rustls::Accept first pub struct TlsStream { state: State, } impl TlsStream { fn new(stream: C, config: Arc) -> Self { let accept = tokio_rustls::TlsAcceptor::from(config).accept(stream); Self { state: State::Handshaking(accept), } } /// Returns a reference to the underlying IO stream. /// /// This should always return `Some`, except if an error has already been yielded. pub fn io(&self) -> Option<&C> { match &self.state { State::Handshaking(accept) => accept.get_ref(), State::Streaming(stream) => Some(stream.get_ref().0), } } /// Returns a reference to the underlying [`rustls::ServerConnection']. /// /// This will start yielding `Some` only after the handshake has completed. pub fn connection(&self) -> Option<&ServerConnection> { match &self.state { State::Handshaking(_) => None, State::Streaming(stream) => Some(stream.get_ref().1), } } } impl AsyncRead for TlsStream { fn poll_read( self: Pin<&mut Self>, cx: &mut Context, buf: &mut ReadBuf, ) -> Poll> { let pin = self.get_mut(); let accept = match &mut pin.state { State::Handshaking(accept) => accept, State::Streaming(stream) => return Pin::new(stream).poll_read(cx, buf), }; let mut stream = match ready!(Pin::new(accept).poll(cx)) { Ok(stream) => stream, Err(err) => return Poll::Ready(Err(err)), }; let result = Pin::new(&mut stream).poll_read(cx, buf); pin.state = State::Streaming(stream); result } } impl AsyncWrite for TlsStream { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { let pin = self.get_mut(); let accept = match &mut pin.state { State::Handshaking(accept) => accept, State::Streaming(stream) => return Pin::new(stream).poll_write(cx, buf), }; let mut stream = match ready!(Pin::new(accept).poll(cx)) { Ok(stream) => stream, Err(err) => return Poll::Ready(Err(err)), }; let result = Pin::new(&mut stream).poll_write(cx, buf); pin.state = State::Streaming(stream); result } fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &mut self.state { State::Handshaking(_) => Poll::Ready(Ok(())), State::Streaming(stream) => Pin::new(stream).poll_flush(cx), } } fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &mut self.state { State::Handshaking(_) => Poll::Ready(Ok(())), State::Streaming(stream) => Pin::new(stream).poll_shutdown(cx), } } } enum State { Handshaking(tokio_rustls::Accept), Streaming(tokio_rustls::server::TlsStream), } hyper-rustls-0.24.2/src/config.rs000064400000000000000000000055041046102023000150000ustar 00000000000000use rustls::client::WantsTransparencyPolicyOrClientCert; use rustls::{ClientConfig, ConfigBuilder, WantsVerifier}; /// Methods for configuring roots /// /// This adds methods (gated by crate features) for easily configuring /// TLS server roots a rustls ClientConfig will trust. pub trait ConfigBuilderExt { /// This configures the platform's trusted certs, as implemented by /// rustls-native-certs #[cfg(feature = "rustls-native-certs")] #[cfg_attr(docsrs, doc(cfg(feature = "rustls-native-certs")))] fn with_native_roots(self) -> ConfigBuilder; /// This configures the webpki roots, which are Mozilla's set of /// trusted roots as packaged by webpki-roots. #[cfg(feature = "webpki-roots")] #[cfg_attr(docsrs, doc(cfg(feature = "webpki-roots")))] fn with_webpki_roots(self) -> ConfigBuilder; } impl ConfigBuilderExt for ConfigBuilder { #[cfg(feature = "rustls-native-certs")] #[cfg_attr(docsrs, doc(cfg(feature = "rustls-native-certs")))] #[cfg_attr(not(feature = "logging"), allow(unused_variables))] fn with_native_roots(self) -> ConfigBuilder { let mut roots = rustls::RootCertStore::empty(); let mut valid_count = 0; let mut invalid_count = 0; for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") { let cert = rustls::Certificate(cert.0); match roots.add(&cert) { Ok(_) => valid_count += 1, Err(err) => { crate::log::trace!("invalid cert der {:?}", cert.0); crate::log::debug!("certificate parsing failed: {:?}", err); invalid_count += 1 } } } crate::log::debug!( "with_native_roots processed {} valid and {} invalid certs", valid_count, invalid_count ); assert!(!roots.is_empty(), "no CA certificates found"); self.with_root_certificates(roots) } #[cfg(feature = "webpki-roots")] #[cfg_attr(docsrs, doc(cfg(feature = "webpki-roots")))] fn with_webpki_roots(self) -> ConfigBuilder { let mut roots = rustls::RootCertStore::empty(); roots.add_trust_anchors( webpki_roots::TLS_SERVER_ROOTS .iter() .map(|ta| { rustls::OwnedTrustAnchor::from_subject_spki_name_constraints( ta.subject, ta.spki, ta.name_constraints, ) }), ); self.with_root_certificates(roots) } } hyper-rustls-0.24.2/src/connector/builder.rs000064400000000000000000000312771046102023000171610ustar 00000000000000use rustls::ClientConfig; use super::HttpsConnector; #[cfg(any(feature = "rustls-native-certs", feature = "webpki-roots"))] use crate::config::ConfigBuilderExt; #[cfg(feature = "tokio-runtime")] use hyper::client::HttpConnector; /// A builder for an [`HttpsConnector`] /// /// This makes configuration flexible and explicit and ensures connector /// features match crate features /// /// # Examples /// /// ``` /// use hyper_rustls::HttpsConnectorBuilder; /// /// # #[cfg(all(feature = "webpki-roots", feature = "tokio-runtime", feature = "http1"))] /// let https = HttpsConnectorBuilder::new() /// .with_webpki_roots() /// .https_only() /// .enable_http1() /// .build(); /// ``` pub struct ConnectorBuilder(State); /// State of a builder that needs a TLS client config next pub struct WantsTlsConfig(()); impl ConnectorBuilder { /// Creates a new [`ConnectorBuilder`] pub fn new() -> Self { Self(WantsTlsConfig(())) } /// Passes a rustls [`ClientConfig`] to configure the TLS connection /// /// The [`alpn_protocols`](ClientConfig::alpn_protocols) field is /// required to be empty (or the function will panic) and will be /// rewritten to match the enabled schemes (see /// [`enable_http1`](ConnectorBuilder::enable_http1), /// [`enable_http2`](ConnectorBuilder::enable_http2)) before the /// connector is built. pub fn with_tls_config(self, config: ClientConfig) -> ConnectorBuilder { assert!( config.alpn_protocols.is_empty(), "ALPN protocols should not be pre-defined" ); ConnectorBuilder(WantsSchemes { tls_config: config }) } /// Shorthand for using rustls' [safe defaults][with_safe_defaults] /// and native roots /// /// See [`ConfigBuilderExt::with_native_roots`] /// /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults #[cfg(feature = "rustls-native-certs")] #[cfg_attr(docsrs, doc(cfg(feature = "rustls-native-certs")))] pub fn with_native_roots(self) -> ConnectorBuilder { self.with_tls_config( ClientConfig::builder() .with_safe_defaults() .with_native_roots() .with_no_client_auth(), ) } /// Shorthand for using rustls' [safe defaults][with_safe_defaults] /// and Mozilla roots /// /// See [`ConfigBuilderExt::with_webpki_roots`] /// /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults #[cfg(feature = "webpki-roots")] #[cfg_attr(docsrs, doc(cfg(feature = "webpki-roots")))] pub fn with_webpki_roots(self) -> ConnectorBuilder { self.with_tls_config( ClientConfig::builder() .with_safe_defaults() .with_webpki_roots() .with_no_client_auth(), ) } } impl Default for ConnectorBuilder { fn default() -> Self { Self::new() } } /// State of a builder that needs schemes (https:// and http://) to be /// configured next pub struct WantsSchemes { tls_config: ClientConfig, } impl ConnectorBuilder { /// Enforce the use of HTTPS when connecting /// /// Only URLs using the HTTPS scheme will be connectable. pub fn https_only(self) -> ConnectorBuilder { ConnectorBuilder(WantsProtocols1 { tls_config: self.0.tls_config, https_only: true, override_server_name: None, }) } /// Allow both HTTPS and HTTP when connecting /// /// HTTPS URLs will be handled through rustls, /// HTTP URLs will be handled by the lower-level connector. pub fn https_or_http(self) -> ConnectorBuilder { ConnectorBuilder(WantsProtocols1 { tls_config: self.0.tls_config, https_only: false, override_server_name: None, }) } } /// State of a builder that needs to have some protocols (HTTP1 or later) /// enabled next /// /// No protocol has been enabled at this point. pub struct WantsProtocols1 { tls_config: ClientConfig, https_only: bool, override_server_name: Option, } impl WantsProtocols1 { fn wrap_connector(self, conn: H) -> HttpsConnector { HttpsConnector { force_https: self.https_only, http: conn, tls_config: std::sync::Arc::new(self.tls_config), override_server_name: self.override_server_name, } } #[cfg(feature = "tokio-runtime")] fn build(self) -> HttpsConnector { let mut http = HttpConnector::new(); // HttpConnector won't enforce scheme, but HttpsConnector will http.enforce_http(false); self.wrap_connector(http) } } impl ConnectorBuilder { /// Enable HTTP1 /// /// This needs to be called explicitly, no protocol is enabled by default #[cfg(feature = "http1")] pub fn enable_http1(self) -> ConnectorBuilder { ConnectorBuilder(WantsProtocols2 { inner: self.0 }) } /// Enable HTTP2 /// /// This needs to be called explicitly, no protocol is enabled by default #[cfg(feature = "http2")] #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] pub fn enable_http2(mut self) -> ConnectorBuilder { self.0.tls_config.alpn_protocols = vec![b"h2".to_vec()]; ConnectorBuilder(WantsProtocols3 { inner: self.0, enable_http1: false, }) } /// Enable all HTTP versions built into this library (enabled with Cargo features) /// /// For now, this could enable both HTTP 1 and 2, depending on active features. /// In the future, other supported versions will be enabled as well. #[cfg(feature = "http2")] #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] pub fn enable_all_versions(mut self) -> ConnectorBuilder { #[cfg(feature = "http1")] let alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; #[cfg(not(feature = "http1"))] let alpn_protocols = vec![b"h2".to_vec()]; self.0.tls_config.alpn_protocols = alpn_protocols; ConnectorBuilder(WantsProtocols3 { inner: self.0, enable_http1: cfg!(feature = "http1"), }) } /// Override server name for the TLS stack /// /// By default, for each connection hyper-rustls will extract host portion /// of the destination URL and verify that server certificate contains /// this value. /// /// If this method is called, hyper-rustls will instead verify that server /// certificate contains `override_server_name`. Domain name included in /// the URL will not affect certificate validation. pub fn with_server_name(mut self, override_server_name: String) -> Self { self.0.override_server_name = Some(override_server_name); self } } /// State of a builder with HTTP1 enabled, that may have some other /// protocols (HTTP2 or later) enabled next /// /// At this point a connector can be built, see /// [`build`](ConnectorBuilder::build) and /// [`wrap_connector`](ConnectorBuilder::wrap_connector). pub struct WantsProtocols2 { inner: WantsProtocols1, } impl ConnectorBuilder { /// Enable HTTP2 /// /// This needs to be called explicitly, no protocol is enabled by default #[cfg(feature = "http2")] #[cfg_attr(docsrs, doc(cfg(feature = "http2")))] pub fn enable_http2(mut self) -> ConnectorBuilder { self.0.inner.tls_config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; ConnectorBuilder(WantsProtocols3 { inner: self.0.inner, enable_http1: true, }) } /// This builds an [`HttpsConnector`] built on hyper's default [`HttpConnector`] #[cfg(feature = "tokio-runtime")] pub fn build(self) -> HttpsConnector { self.0.inner.build() } /// This wraps an arbitrary low-level connector into an [`HttpsConnector`] pub fn wrap_connector(self, conn: H) -> HttpsConnector { // HTTP1-only, alpn_protocols stays empty // HttpConnector doesn't have a way to say http1-only; // its connection pool may still support HTTP2 // though it won't be used self.0.inner.wrap_connector(conn) } } /// State of a builder with HTTP2 (and possibly HTTP1) enabled /// /// At this point a connector can be built, see /// [`build`](ConnectorBuilder::build) and /// [`wrap_connector`](ConnectorBuilder::wrap_connector). #[cfg(feature = "http2")] pub struct WantsProtocols3 { inner: WantsProtocols1, // ALPN is built piecemeal without the need to read back this field #[allow(dead_code)] enable_http1: bool, } #[cfg(feature = "http2")] impl ConnectorBuilder { /// This builds an [`HttpsConnector`] built on hyper's default [`HttpConnector`] #[cfg(feature = "tokio-runtime")] pub fn build(self) -> HttpsConnector { self.0.inner.build() } /// This wraps an arbitrary low-level connector into an [`HttpsConnector`] pub fn wrap_connector(self, conn: H) -> HttpsConnector { // If HTTP1 is disabled, we can set http2_only // on the Client (a higher-level object that uses the connector) // client.http2_only(!self.0.enable_http1); self.0.inner.wrap_connector(conn) } } #[cfg(test)] mod tests { // Typical usage #[test] #[cfg(all(feature = "webpki-roots", feature = "http1"))] fn test_builder() { let _connector = super::ConnectorBuilder::new() .with_webpki_roots() .https_only() .enable_http1() .build(); } #[test] #[cfg(feature = "http1")] #[should_panic(expected = "ALPN protocols should not be pre-defined")] fn test_reject_predefined_alpn() { let roots = rustls::RootCertStore::empty(); let mut config_with_alpn = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(roots) .with_no_client_auth(); config_with_alpn.alpn_protocols = vec![b"fancyprotocol".to_vec()]; let _connector = super::ConnectorBuilder::new() .with_tls_config(config_with_alpn) .https_only() .enable_http1() .build(); } #[test] #[cfg(all(feature = "http1", feature = "http2"))] fn test_alpn() { let roots = rustls::RootCertStore::empty(); let tls_config = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(roots) .with_no_client_auth(); let connector = super::ConnectorBuilder::new() .with_tls_config(tls_config.clone()) .https_only() .enable_http1() .build(); assert!(connector .tls_config .alpn_protocols .is_empty()); let connector = super::ConnectorBuilder::new() .with_tls_config(tls_config.clone()) .https_only() .enable_http2() .build(); assert_eq!(&connector.tls_config.alpn_protocols, &[b"h2".to_vec()]); let connector = super::ConnectorBuilder::new() .with_tls_config(tls_config.clone()) .https_only() .enable_http1() .enable_http2() .build(); assert_eq!( &connector.tls_config.alpn_protocols, &[b"h2".to_vec(), b"http/1.1".to_vec()] ); let connector = super::ConnectorBuilder::new() .with_tls_config(tls_config) .https_only() .enable_all_versions() .build(); assert_eq!( &connector.tls_config.alpn_protocols, &[b"h2".to_vec(), b"http/1.1".to_vec()] ); } #[test] #[cfg(all(not(feature = "http1"), feature = "http2"))] fn test_alpn_http2() { let roots = rustls::RootCertStore::empty(); let tls_config = rustls::ClientConfig::builder() .with_safe_defaults() .with_root_certificates(roots) .with_no_client_auth(); let connector = super::ConnectorBuilder::new() .with_tls_config(tls_config.clone()) .https_only() .enable_http2() .build(); assert_eq!(&connector.tls_config.alpn_protocols, &[b"h2".to_vec()]); let connector = super::ConnectorBuilder::new() .with_tls_config(tls_config) .https_only() .enable_all_versions() .build(); assert_eq!(&connector.tls_config.alpn_protocols, &[b"h2".to_vec()]); } } hyper-rustls-0.24.2/src/connector.rs000064400000000000000000000107771046102023000155350ustar 00000000000000use std::future::Future; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use std::{fmt, io}; use hyper::{client::connect::Connection, service::Service, Uri}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_rustls::TlsConnector; use crate::stream::MaybeHttpsStream; pub(crate) mod builder; type BoxError = Box; /// A Connector for the `https` scheme. #[derive(Clone)] pub struct HttpsConnector { force_https: bool, http: T, tls_config: Arc, override_server_name: Option, } impl HttpsConnector { /// Force the use of HTTPS when connecting. /// /// If a URL is not `https` when connecting, an error is returned. pub fn enforce_https(&mut self) { self.force_https = true; } } impl fmt::Debug for HttpsConnector { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("HttpsConnector") .field("force_https", &self.force_https) .finish() } } impl From<(H, C)> for HttpsConnector where C: Into>, { fn from((http, cfg): (H, C)) -> Self { Self { force_https: false, http, tls_config: cfg.into(), override_server_name: None, } } } impl Service for HttpsConnector where T: Service, T::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, T::Future: Send + 'static, T::Error: Into, { type Response = MaybeHttpsStream; type Error = BoxError; #[allow(clippy::type_complexity)] type Future = Pin, BoxError>> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { match self.http.poll_ready(cx) { Poll::Ready(Ok(())) => Poll::Ready(Ok(())), Poll::Ready(Err(e)) => Poll::Ready(Err(e.into())), Poll::Pending => Poll::Pending, } } fn call(&mut self, dst: Uri) -> Self::Future { // dst.scheme() would need to derive Eq to be matchable; // use an if cascade instead if let Some(sch) = dst.scheme() { if sch == &http::uri::Scheme::HTTP && !self.force_https { let connecting_future = self.http.call(dst); let f = async move { let tcp = connecting_future .await .map_err(Into::into)?; Ok(MaybeHttpsStream::Http(tcp)) }; Box::pin(f) } else if sch == &http::uri::Scheme::HTTPS { let cfg = self.tls_config.clone(); let mut hostname = match self.override_server_name.as_deref() { Some(h) => h, None => dst.host().unwrap_or_default(), }; // Remove square brackets around IPv6 address. if let Some(trimmed) = hostname .strip_prefix('[') .and_then(|h| h.strip_suffix(']')) { hostname = trimmed; } let hostname = match rustls::ServerName::try_from(hostname) { Ok(dnsname) => dnsname, Err(_) => { let err = io::Error::new(io::ErrorKind::Other, "invalid dnsname"); return Box::pin(async move { Err(Box::new(err).into()) }); } }; let connecting_future = self.http.call(dst); let f = async move { let tcp = connecting_future .await .map_err(Into::into)?; let connector = TlsConnector::from(cfg); let tls = connector .connect(hostname, tcp) .await .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; Ok(MaybeHttpsStream::Https(tls)) }; Box::pin(f) } else { let err = io::Error::new(io::ErrorKind::Other, format!("Unsupported scheme {}", sch)); Box::pin(async move { Err(err.into()) }) } } else { let err = io::Error::new(io::ErrorKind::Other, "Missing scheme"); Box::pin(async move { Err(err.into()) }) } } } hyper-rustls-0.24.2/src/lib.rs000064400000000000000000000075601046102023000143050ustar 00000000000000//! # hyper-rustls //! //! A pure-Rust HTTPS connector for [hyper](https://hyper.rs), based on //! [Rustls](https://github.com/rustls/rustls). //! //! ## Example client //! //! ```no_run //! # #[cfg(all(feature = "rustls-native-certs", feature = "tokio-runtime", feature = "http1"))] //! # fn main() { //! use hyper::{Body, Client, StatusCode, Uri}; //! //! let mut rt = tokio::runtime::Runtime::new().unwrap(); //! let url = ("https://hyper.rs").parse().unwrap(); //! let https = hyper_rustls::HttpsConnectorBuilder::new() //! .with_native_roots() //! .https_only() //! .enable_http1() //! .build(); //! //! let client: Client<_, hyper::Body> = Client::builder().build(https); //! //! let res = rt.block_on(client.get(url)).unwrap(); //! assert_eq!(res.status(), StatusCode::OK); //! # } //! # #[cfg(not(all(feature = "rustls-native-certs", feature = "tokio-runtime", feature = "http1")))] //! # fn main() {} //! ``` //! //! ## Example server //! //! ```no_run //! # #[cfg(all(feature = "rustls-native-certs", feature = "tokio-runtime", feature = "http1", feature = "acceptor"))] //! # fn main() { //! use hyper::server::conn::AddrIncoming; //! use hyper::service::{make_service_fn, service_fn}; //! use hyper::{Body, Method, Request, Response, Server, StatusCode}; //! use hyper_rustls::TlsAcceptor; //! use std::io; //! use std::fs::File; //! //! let mut rt = tokio::runtime::Runtime::new().unwrap(); //! let addr = "127.0.0.1:1337".parse().unwrap(); //! //! // Load public certificate. //! let certfile = File::open("examples/sample.pem").unwrap(); //! let mut reader = io::BufReader::new(certfile); //! //! // Load and return certificate. //! let certs = rustls_pemfile::certs(&mut reader).unwrap(); //! let certs = certs.into_iter().map(rustls::Certificate).collect(); //! //! // Load private key. (see `examples/server.rs`) //! let keyfile = File::open("examples/sample.rsa").unwrap(); //! let mut reader = io::BufReader::new(keyfile); //! //! // Load and return a single private key. //! let keys = rustls_pemfile::rsa_private_keys(&mut reader).unwrap(); //! let key = rustls::PrivateKey(keys[0].clone()); //! let https = hyper_rustls::HttpsConnectorBuilder::new() //! .with_native_roots() //! .https_only() //! .enable_http1() //! .build(); //! //! let incoming = AddrIncoming::bind(&addr).unwrap(); //! let acceptor = TlsAcceptor::builder() //! .with_single_cert(certs, key).unwrap() //! .with_all_versions_alpn() //! .with_incoming(incoming); //! let service = make_service_fn(|_| async { Ok::<_, io::Error>(service_fn(|_req|async {Ok::<_, io::Error>(Response::new(Body::empty()))})) }); //! let server = Server::builder(acceptor).serve(service); //! // server.await.unwrap(); //! # } //! # #[cfg(not(all(feature = "rustls-native-certs", feature = "tokio-runtime", feature = "http1")))] //! # fn main() {} //! ``` #![warn(missing_docs, unreachable_pub, clippy::use_self)] #![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(feature = "acceptor")] /// TLS acceptor implementing hyper's `Accept` trait. pub mod acceptor; mod config; mod connector; mod stream; #[cfg(feature = "logging")] mod log { pub(crate) use log::{debug, trace}; } #[cfg(not(feature = "logging"))] mod log { macro_rules! trace ( ($($tt:tt)*) => {{}} ); macro_rules! debug ( ($($tt:tt)*) => {{}} ); pub(crate) use {debug, trace}; } #[cfg(feature = "acceptor")] pub use crate::acceptor::{AcceptorBuilder, TlsAcceptor}; pub use crate::config::ConfigBuilderExt; pub use crate::connector::builder::ConnectorBuilder as HttpsConnectorBuilder; pub use crate::connector::HttpsConnector; pub use crate::stream::MaybeHttpsStream; /// The various states of the [`HttpsConnectorBuilder`] pub mod builderstates { #[cfg(feature = "http2")] pub use crate::connector::builder::WantsProtocols3; pub use crate::connector::builder::{ WantsProtocols1, WantsProtocols2, WantsSchemes, WantsTlsConfig, }; } hyper-rustls-0.24.2/src/stream.rs000064400000000000000000000054731046102023000150330ustar 00000000000000// Copied from hyperium/hyper-tls#62e3376/src/stream.rs use std::fmt; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; use hyper::client::connect::{Connected, Connection}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio_rustls::client::TlsStream; /// A stream that might be protected with TLS. #[allow(clippy::large_enum_variant)] pub enum MaybeHttpsStream { /// A stream over plain text. Http(T), /// A stream protected with TLS. Https(TlsStream), } impl Connection for MaybeHttpsStream { fn connected(&self) -> Connected { match self { Self::Http(s) => s.connected(), Self::Https(s) => { let (tcp, tls) = s.get_ref(); if tls.alpn_protocol() == Some(b"h2") { tcp.connected().negotiated_h2() } else { tcp.connected() } } } } } impl fmt::Debug for MaybeHttpsStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Self::Http(..) => f.pad("Http(..)"), Self::Https(..) => f.pad("Https(..)"), } } } impl From for MaybeHttpsStream { fn from(inner: T) -> Self { Self::Http(inner) } } impl From> for MaybeHttpsStream { fn from(inner: TlsStream) -> Self { Self::Https(inner) } } impl AsyncRead for MaybeHttpsStream { #[inline] fn poll_read( self: Pin<&mut Self>, cx: &mut Context, buf: &mut ReadBuf<'_>, ) -> Poll> { match Pin::get_mut(self) { Self::Http(s) => Pin::new(s).poll_read(cx, buf), Self::Https(s) => Pin::new(s).poll_read(cx, buf), } } } impl AsyncWrite for MaybeHttpsStream { #[inline] fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { match Pin::get_mut(self) { Self::Http(s) => Pin::new(s).poll_write(cx, buf), Self::Https(s) => Pin::new(s).poll_write(cx, buf), } } #[inline] fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match Pin::get_mut(self) { Self::Http(s) => Pin::new(s).poll_flush(cx), Self::Https(s) => Pin::new(s).poll_flush(cx), } } #[inline] fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match Pin::get_mut(self) { Self::Http(s) => Pin::new(s).poll_shutdown(cx), Self::Https(s) => Pin::new(s).poll_shutdown(cx), } } } hyper-rustls-0.24.2/tests/tests.rs000064400000000000000000000045211046102023000152460ustar 00000000000000use std::env; use std::net::TcpStream; use std::path::PathBuf; use std::process::Command; use std::thread; use std::time; fn examples_dir() -> PathBuf { let target_dir: PathBuf = env::var("CARGO_TARGET_DIR") .unwrap_or_else(|_| "target".to_string()) .into(); target_dir .join("debug") .join("examples") } fn server_command() -> Command { Command::new(examples_dir().join("server")) } fn client_command() -> Command { Command::new(examples_dir().join("client")) } fn wait_for_server(addr: &str) { for i in 0..10 { if TcpStream::connect(addr).is_ok() { return; } thread::sleep(time::Duration::from_millis(i * 100)); } panic!("failed to connect to {:?} after 10 tries", addr); } #[test] fn client() { let rc = client_command() .arg("https://google.com") .output() .expect("cannot run client example"); assert!(rc.status.success()); } #[cfg(feature = "acceptor")] #[test] fn server() { let mut srv = server_command() .arg("1337") .spawn() .expect("cannot run server example"); let addr = "localhost:1337"; wait_for_server(addr); let output = Command::new("curl") .arg("--insecure") .arg("--http1.0") .arg(format!("https://{}", addr)) .output() .expect("cannot run curl"); srv.kill().unwrap(); if !output.status.success() { let version_stdout = Command::new("curl") .arg("--version") .output() .expect("cannot run curl to collect --version") .stdout; println!("curl version: {}", String::from_utf8_lossy(&version_stdout)); println!("curl stderr:\n{}", String::from_utf8_lossy(&output.stderr)); } assert_eq!(String::from_utf8_lossy(&output.stdout), "Try POST /echo\n"); } #[test] fn custom_ca_store() { let mut srv = server_command() .arg("1338") .spawn() .expect("cannot run server example"); let addr = "localhost:1338"; wait_for_server(addr); let rc = client_command() .arg(format!("https://{}", addr)) .arg("examples/sample.pem") .output() .expect("cannot run client example"); srv.kill().unwrap(); if !rc.status.success() { assert_eq!(String::from_utf8_lossy(&rc.stdout), ""); } }