Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

correctly parse x509 certificates for channel binding #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod private {
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio_postgres::tls::{ChannelBinding, TlsConnect};
use tokio_rustls::{client::TlsStream, TlsConnector};
use x509_cert::{der::Decode, TbsCertificate};
use x509_cert::{der::Decode, Certificate};

pub struct TlsConnectFuture<S> {
pub inner: tokio_rustls::Connect<S>,
Expand Down Expand Up @@ -91,10 +91,10 @@ mod private {
fn channel_binding(&self) -> ChannelBinding {
let (_, session) = self.0.get_ref();
match session.peer_certificates() {
Some(certs) if !certs.is_empty() => TbsCertificate::from_der(&certs[0])
Some(certs) if !certs.is_empty() => Certificate::from_der(&certs[0])
.ok()
.and_then(|cert| {
let digest = match cert.signature.oid {
let digest = match cert.signature_algorithm.oid {
// Note: SHA1 is upgraded to SHA256 as per https://datatracker.ietf.org/doc/html/rfc5929#section-4.1
ID_SHA_1
| ID_SHA_256
Expand Down