blob: a9c32eeae3bae21b97136a51dd5f4ac58bee3264 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Something that can verify a server certificate chain, and verify signatures made by certificates."><meta name="keywords" content="rust, rustlang, rust-lang, ServerCertVerifier"><title>ServerCertVerifier in rustls - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../rustls/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../rustls/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">ServerCertVerifier</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.verify_server_cert">verify_server_cert</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.supported_verify_schemes">supported_verify_schemes</a></li><li><a href="#method.verify_tls12_signature">verify_tls12_signature</a></li><li><a href="#method.verify_tls13_signature">verify_tls13_signature</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In rustls</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="index.html">rustls</a>::<wbr><a class="trait" href="#">ServerCertVerifier</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/rustls/verify.rs.html#81-152">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait ServerCertVerifier: Send + Sync {
fn <a href="#tymethod.verify_server_cert" class="fnname">verify_server_cert</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;roots: &amp;<a class="struct" href="struct.RootCertStore.html" title="struct rustls::RootCertStore">RootCertStore</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;presented_certs: &amp;[<a class="struct" href="struct.Certificate.html" title="struct rustls::Certificate">Certificate</a>],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dns_name: <a class="struct" href="../webpki/name/struct.DNSNameRef.html" title="struct webpki::name::DNSNameRef">DNSNameRef</a>&lt;'_&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ocsp_response: &amp;[u8]<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; Result&lt;<a class="struct" href="struct.ServerCertVerified.html" title="struct rustls::ServerCertVerified">ServerCertVerified</a>, <a class="enum" href="enum.TLSError.html" title="enum rustls::TLSError">TLSError</a>&gt;;
fn <a href="#method.verify_tls12_signature" class="fnname">verify_tls12_signature</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message: &amp;[u8],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cert: &amp;<a class="struct" href="struct.Certificate.html" title="struct rustls::Certificate">Certificate</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dss: &amp;<a class="struct" href="internal/msgs/handshake/struct.DigitallySignedStruct.html" title="struct rustls::internal::msgs::handshake::DigitallySignedStruct">DigitallySignedStruct</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; Result&lt;<a class="struct" href="struct.HandshakeSignatureValid.html" title="struct rustls::HandshakeSignatureValid">HandshakeSignatureValid</a>, <a class="enum" href="enum.TLSError.html" title="enum rustls::TLSError">TLSError</a>&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.verify_tls13_signature" class="fnname">verify_tls13_signature</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message: &amp;[u8],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cert: &amp;<a class="struct" href="struct.Certificate.html" title="struct rustls::Certificate">Certificate</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dss: &amp;<a class="struct" href="internal/msgs/handshake/struct.DigitallySignedStruct.html" title="struct rustls::internal::msgs::handshake::DigitallySignedStruct">DigitallySignedStruct</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; Result&lt;<a class="struct" href="struct.HandshakeSignatureValid.html" title="struct rustls::HandshakeSignatureValid">HandshakeSignatureValid</a>, <a class="enum" href="enum.TLSError.html" title="enum rustls::TLSError">TLSError</a>&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.supported_verify_schemes" class="fnname">supported_verify_schemes</a>(&amp;self) -&gt; Vec&lt;<a class="enum" href="internal/msgs/enums/enum.SignatureScheme.html" title="enum rustls::internal::msgs::enums::SignatureScheme">SignatureScheme</a>&gt; { ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Something that can verify a server certificate chain, and verify
signatures made by certificates.</p>
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.verify_server_cert" class="method has-srclink"><a class="srclink rightside" href="../src/rustls/verify.rs.html#85-91">source</a><h4 class="code-header">fn <a href="#tymethod.verify_server_cert" class="fnname">verify_server_cert</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;roots: &amp;<a class="struct" href="struct.RootCertStore.html" title="struct rustls::RootCertStore">RootCertStore</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;presented_certs: &amp;[<a class="struct" href="struct.Certificate.html" title="struct rustls::Certificate">Certificate</a>],<br>&nbsp;&nbsp;&nbsp;&nbsp;dns_name: <a class="struct" href="../webpki/name/struct.DNSNameRef.html" title="struct webpki::name::DNSNameRef">DNSNameRef</a>&lt;'_&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;ocsp_response: &amp;[u8]<br>) -&gt; Result&lt;<a class="struct" href="struct.ServerCertVerified.html" title="struct rustls::ServerCertVerified">ServerCertVerified</a>, <a class="enum" href="enum.TLSError.html" title="enum rustls::TLSError">TLSError</a>&gt;</h4></section></summary><div class="docblock"><p>Verify a the certificate chain <code>presented_certs</code> against the roots
configured in <code>roots</code>. Make sure that <code>dns_name</code> is quoted by
the top certificate in the chain.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.verify_tls12_signature" class="method has-srclink"><a class="srclink rightside" href="../src/rustls/verify.rs.html#112-119">source</a><h4 class="code-header">fn <a href="#method.verify_tls12_signature" class="fnname">verify_tls12_signature</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;message: &amp;[u8],<br>&nbsp;&nbsp;&nbsp;&nbsp;cert: &amp;<a class="struct" href="struct.Certificate.html" title="struct rustls::Certificate">Certificate</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;dss: &amp;<a class="struct" href="internal/msgs/handshake/struct.DigitallySignedStruct.html" title="struct rustls::internal::msgs::handshake::DigitallySignedStruct">DigitallySignedStruct</a><br>) -&gt; Result&lt;<a class="struct" href="struct.HandshakeSignatureValid.html" title="struct rustls::HandshakeSignatureValid">HandshakeSignatureValid</a>, <a class="enum" href="enum.TLSError.html" title="enum rustls::TLSError">TLSError</a>&gt;</h4></section></summary><div class="docblock"><p>Verify a signature allegedly by the given server certificate.</p>
<p><code>message</code> is not hashed, and needs hashing during the verification.
The signature and algorithm are within <code>dss</code>. <code>cert</code> contains the
public key to use.</p>
<p><code>cert</code> is the same certificate that was previously validated by a
call to <code>verify_server_cert</code>.</p>
<p>If and only if the signature is valid, return HandshakeSignatureValid.
Otherwise, return an error – rustls will send an alert and abort the
connection.</p>
<p>This method is only called for TLS1.2 handshakes. Note that, in TLS1.2,
SignatureSchemes such as <code>SignatureScheme::ECDSA_NISTP256_SHA256</code> are not
in fact bound to the specific curve implied in their name.</p>
<p>This trait method has a default implementation that uses webpki to verify
the signature.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.verify_tls13_signature" class="method has-srclink"><a class="srclink rightside" href="../src/rustls/verify.rs.html#133-140">source</a><h4 class="code-header">fn <a href="#method.verify_tls13_signature" class="fnname">verify_tls13_signature</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;message: &amp;[u8],<br>&nbsp;&nbsp;&nbsp;&nbsp;cert: &amp;<a class="struct" href="struct.Certificate.html" title="struct rustls::Certificate">Certificate</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;dss: &amp;<a class="struct" href="internal/msgs/handshake/struct.DigitallySignedStruct.html" title="struct rustls::internal::msgs::handshake::DigitallySignedStruct">DigitallySignedStruct</a><br>) -&gt; Result&lt;<a class="struct" href="struct.HandshakeSignatureValid.html" title="struct rustls::HandshakeSignatureValid">HandshakeSignatureValid</a>, <a class="enum" href="enum.TLSError.html" title="enum rustls::TLSError">TLSError</a>&gt;</h4></section></summary><div class="docblock"><p>Verify a signature allegedly by the given server certificate.</p>
<p>This method is only called for TLS1.3 handshakes.</p>
<p>This method is very similar to <code>verify_tls12_signature</code>: but note the
tighter ECDSA SignatureScheme semantics – eg <code>SignatureScheme::ECDSA_NISTP256_SHA256</code>
must only validate signatures using public keys on the right curve –
rustls does not enforce this requirement for you.</p>
<p>This trait method has a default implementation that uses webpki to verify
the signature.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.supported_verify_schemes" class="method has-srclink"><a class="srclink rightside" href="../src/rustls/verify.rs.html#149-151">source</a><h4 class="code-header">fn <a href="#method.supported_verify_schemes" class="fnname">supported_verify_schemes</a>(&amp;self) -&gt; Vec&lt;<a class="enum" href="internal/msgs/enums/enum.SignatureScheme.html" title="enum rustls::internal::msgs::enums::SignatureScheme">SignatureScheme</a>&gt;</h4></section></summary><div class="docblock"><p>Return the list of SignatureSchemes that this verifier will handle,
in <code>verify_tls12_signature</code> and <code>verify_tls13_signature</code> calls.</p>
<p>This should be in priority order, with the most preferred first.</p>
<p>This trait mehod has a default implementation that reflects the schemes
supported by webpki.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><section id="impl-ServerCertVerifier-for-WebPKIVerifier" class="impl has-srclink"><a class="srclink rightside" href="../src/rustls/verify.rs.html#255-288">source</a><a href="#impl-ServerCertVerifier-for-WebPKIVerifier" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="trait.ServerCertVerifier.html" title="trait rustls::ServerCertVerifier">ServerCertVerifier</a> for <a class="struct" href="struct.WebPKIVerifier.html" title="struct rustls::WebPKIVerifier">WebPKIVerifier</a></h3></section></div><script src="../implementors/rustls/verify/trait.ServerCertVerifier.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="rustls" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>