浏览代码

re-eable encryption of mq payloads

Matthew R Kasun 2 年之前
父节点
当前提交
3c4f4dda4d
共有 1 个文件被更改,包括 6 次插入7 次删除
  1. 6 7
      mq/util.go

+ 6 - 7
mq/util.go

@@ -13,9 +13,9 @@ import (
 )
 
 func decryptMsgWithHost(host *models.Host, msg []byte) ([]byte, error) {
-	//if host.OS == models.OS_Types.IoT { // just pass along IoT messages
-	return msg, nil
-	//}
+	if host.OS == models.OS_Types.IoT { // just pass along IoT messages
+		return msg, nil
+	}
 
 	trafficKey, trafficErr := logic.RetrievePrivateTrafficKey() // get server private key
 	if trafficErr != nil {
@@ -34,7 +34,6 @@ func decryptMsgWithHost(host *models.Host, msg []byte) ([]byte, error) {
 }
 
 func decryptMsg(node *models.Node, msg []byte) ([]byte, error) {
-	return msg, nil
 	if len(msg) <= 24 { // make sure message is of appropriate length
 		return nil, fmt.Errorf("recieved invalid message from broker %v", msg)
 	}
@@ -47,9 +46,9 @@ func decryptMsg(node *models.Node, msg []byte) ([]byte, error) {
 }
 
 func encryptMsg(host *models.Host, msg []byte) ([]byte, error) {
-	//if host.OS == models.OS_Types.IoT {
-	return msg, nil
-	//}
+	if host.OS == models.OS_Types.IoT {
+		return msg, nil
+	}
 
 	// fetch server public key to be certain hasn't changed in transit
 	trafficKey, trafficErr := logic.RetrievePrivateTrafficKey()