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

A tiny fix to Kerberos inner initiate sercurity context #179

Closed
Closed
Show file tree
Hide file tree
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
9 changes: 1 addition & 8 deletions src/kerberos/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ use crate::kdc::detect_kdc_url;
use crate::negotiate::{NegotiatedProtocol, ProtocolConfig};
use crate::{Kerberos, Result};

#[derive(Debug)]
pub struct KerberosConfig {
pub url: Option<Url>,
pub hostname: Option<String>,
}

impl Debug for KerberosConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("KerberosConfig")
.field("url", &self.url)
.finish_non_exhaustive()
}
}

impl ProtocolConfig for KerberosConfig {
fn new_client(&self) -> Result<NegotiatedProtocol> {
Ok(NegotiatedProtocol::Kerberos(Kerberos::new_client_from_config(
Expand Down
2 changes: 1 addition & 1 deletion src/kerberos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ impl<'a> Kerberos {
Ok(())
}

pub async fn initialize_security_context_impl(
pub(crate) async fn initialize_security_context_impl(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate what is fixed by this, please?

&'a mut self,
yield_point: &mut YieldPointLocal,
builder: &'a mut crate::builders::FilledInitializeSecurityContext<'_, <Self as SspiImpl>::CredentialsHandle>,
Expand Down
2 changes: 1 addition & 1 deletion src/negotiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl Negotiate {
match &negotiated_protocol {
NegotiatedProtocol::Pku2u(pku2u) => {
if !is_pku2u {
let ntlm_config = NtlmConfig::new(pku2u.config().hostname.clone());
let ntlm_config = NtlmConfig::new(pku2u.config().client_hostname.clone());
filtered_protocol = Some(NegotiatedProtocol::Ntlm(Ntlm::with_config(ntlm_config)));
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/pku2u/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ use crate::{Pku2u, Result};
pub struct Pku2uConfig {
pub p2p_certificate: Certificate,
pub private_key: SecretPrivateKey,
pub hostname: String,
pub client_hostname: String,
}

impl Pku2uConfig {
pub fn new(p2p_certificate: Certificate, private_key: PrivateKey, hostname: String) -> Self {
pub fn new(p2p_certificate: Certificate, private_key: PrivateKey, client_hostname: String) -> Self {
Self {
p2p_certificate,
private_key: private_key.into(),
hostname,
client_hostname,
}
}

#[cfg(target_os = "windows")]
pub fn default_client_config(hostname: String) -> Result<Self> {
pub fn default_client_config(client_hostname: String) -> Result<Self> {
use super::cert_utils::extraction::extract_client_p2p_cert_and_key;

let (p2p_certificate, private_key) = extract_client_p2p_cert_and_key()?;

Ok(Self {
p2p_certificate,
private_key: private_key.into(),
hostname,
client_hostname,
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/pku2u/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl Pku2u {
snames: &snames,
// we don't need the nonce in Pku2u
nonce: &[0],
hostname: &self.config.hostname,
hostname: &self.config.client_hostname,
context_requirements: builder.context_requirements,
})?;
let private_key = self.config.private_key.clone();
Expand Down Expand Up @@ -925,7 +925,7 @@ xFnLp2UBrhxA9GYrpJ5i0onRmexQnTVSl5DDq07s+3dbr9YAKjrg9IDZYqLbdwP1
config: Pku2uConfig {
p2p_certificate: p2p_certificate.clone(),
private_key: private_key.clone().into(),
hostname: "hostname".into(),
client_hostname: "hostname".into(),
},
state: Pku2uState::Final,
encryption_params: EncryptionParams {
Expand All @@ -950,7 +950,7 @@ xFnLp2UBrhxA9GYrpJ5i0onRmexQnTVSl5DDq07s+3dbr9YAKjrg9IDZYqLbdwP1
config: Pku2uConfig {
p2p_certificate,
private_key: private_key.into(),
hostname: "hostname".into(),
client_hostname: "hostname".into(),
},
state: Pku2uState::Final,
encryption_params: EncryptionParams {
Expand Down