Page MenuHomePhabricator

D5947.id19723.diff
No OneTemporary

D5947.id19723.diff

diff --git a/services/tunnelbroker/src/server/mod.rs b/services/tunnelbroker/src/server/mod.rs
--- a/services/tunnelbroker/src/server/mod.rs
+++ b/services/tunnelbroker/src/server/mod.rs
@@ -3,8 +3,8 @@
use super::constants;
use super::cxx_bridge::ffi::{
ackMessageFromAMQP, eraseMessagesFromAMQP, getMessagesFromDatabase,
- getSessionItem, newSessionHandler, removeMessages, sendMessages,
- sessionSignatureHandler, updateSessionItemDeviceToken,
+ getSessionItem, getStringToSign, newSessionHandler, removeMessages,
+ sendMessages, sessionSignatureHandler, updateSessionItemDeviceToken,
updateSessionItemIsOnline, waitMessageFromDeliveryBroker, GRPCStatusCodes,
};
use anyhow::Result;
@@ -61,6 +61,37 @@
));
};
+ let string_to_be_signed: String;
+ match getStringToSign(&inner_request.device_id) {
+ Ok(string_from_database) => string_to_be_signed = string_from_database,
+ Err(err) => {
+ return Err(tools::create_tonic_status(
+ GRPCStatusCodes::Internal,
+ &err.what(),
+ ))
+ }
+ }
+ match tools::verify_signed_string(
+ &inner_request.public_key,
+ &string_to_be_signed,
+ &inner_request.signature,
+ ) {
+ Ok(verifying_result) => {
+ if !verifying_result {
+ return Err(tools::create_tonic_status(
+ GRPCStatusCodes::PermissionDenied,
+ "Signature for the verification message is not valid",
+ ));
+ }
+ }
+ Err(_) => {
+ return Err(tools::create_tonic_status(
+ GRPCStatusCodes::Internal,
+ "Error while verifying the signature",
+ ))
+ }
+ }
+
let result = newSessionHandler(
&inner_request.device_id,
&inner_request.public_key,

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 3:47 AM (21 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678317
Default Alt Text
D5947.id19723.diff (1 KB)

Event Timeline