-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix the new license flow #43
base: master
Are you sure you want to change the base?
Conversation
8f382cf
to
a2274ea
Compare
b87a883
to
b14690c
Compare
de2196f
to
42efb5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have nearly enough context to understand the business logic parts of this, fwiw.
src/core/license.rs
Outdated
return Err(Error::RdpError(RdpError::new( | ||
RdpErrorKind::InvalidData, | ||
"SEC: Invalid Licence packet", | ||
format!("SEC: Invalid Licence packet (flag={:x})", security_flag).as_str(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format!("SEC: Invalid Licence packet (flag={:x})", security_flag).as_str(), | |
&format!("SEC: Invalid Licence packet (flag={security_flag:x})"), |
/// ServerNewLicense message. | ||
/// | ||
/// See MS-RDPELE section 2.2.2.6. | ||
type ServerUpgradeLicense = ServerNewLicense; | ||
|
||
/// License data that has been obtained from the sever | ||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[allow(dead_code)] |
]; | ||
|
||
message.read(raw)?; | ||
let server_random = cast!(DataType::Slice, message["ServerRandom"])?; | ||
let version = cast!(DataType::U32, message["dwVersion"])?; | ||
let server_certificate = cast!(DataType::Component, message["ServerCertificate"])?; | ||
let mut blob_data = cast!(DataType::Slice, server_certificate["blobData"])?; | ||
let scope_count = cast!(DataType::U32, message["ScopeCount"])?; | ||
|
||
let mut scopes = Vec::with_capacity(scope_count as usize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is that ScopeCount
coming from? Is it trustworthy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's coming from the Windows server that is requesting a license from us.
I've never seen anything other than 1
, but I don't have a very sophisticated setup. Maybe we should put some reasonable maximum (100?) here to avoid unbounded allocations?
(Now that you point this out, the with_capacity
doesn't do much because thats the number of scopes, not any sort of byte-length).
42efb5f
to
06379dd
Compare
Fixes several bugs with the new license flow and allows us to successfully obtain a license. Additionally, use a client-provided UUID to identify the client instead of using the Windows domain (which isn't unique per-agent).
06379dd
to
b5dc810
Compare
cd3ca30
to
bf453b1
Compare
Fixes several bugs with the new license flow and allows us to successfully obtain a license. The next step will be to add hooks to save this license so that we can reuse it for the upgrade license flow on subsequent attempts.
Additionally, uses a client-provided UUID to identify itself to the RDP server for licensing purposes (we were previously using the Windows domain, which would cause all Teleport RDP clients to appear identical to the server).