File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ function processAction(msg, cfg) {
33
33
body : msg . body . payload || msg . body ,
34
34
attachments : msg . attachments
35
35
} ) ;
36
+ console . log ( encryptedData , encryptor . decryptMessageContent ( encryptedData ) ) ;
36
37
channel . publish ( amqpExchange , 'foo' , encryptedData , {
37
38
contentType : "application/octet-stream" ,
38
39
messageId : msg . id
@@ -42,6 +43,10 @@ function processAction(msg, cfg) {
42
43
console . log ( 'Message publishing confirmed id=%s' , msg . id ) ;
43
44
this . emit ( 'data' , msg ) ;
44
45
this . emit ( 'end' ) ;
46
+ console . log ( 'Closing the channel' ) ;
47
+ yield channel . close ( ) ;
48
+ console . log ( 'Closing the connnection' ) ;
49
+ yield conn . close ( ) ;
45
50
} . bind ( this ) ) . catch ( err => {
46
51
console . log ( 'Error occurred' , err . stack || err ) ;
47
52
this . emit ( 'error' , err ) ;
Original file line number Diff line number Diff line change @@ -34,12 +34,9 @@ function encryptIV(rawData) {
34
34
function decryptIV ( encData ) {
35
35
debug ( 'About to decrypt:' , encData ) ;
36
36
37
- if ( ! _ . isString ( encData ) ) {
38
- throw new Error ( 'RabbitMQ message cipher.decryptIV() accepts only string as parameter.' ) ;
39
- }
40
-
41
37
if ( ! PASSWORD ) {
42
- return encData ;
38
+ console . log ( 'Decryption will be skipped as ELASTICIO_MESSAGE_CRYPTO_PASSWORD env is empty' ) ;
39
+ return encData ;
43
40
}
44
41
45
42
if ( ! VECTOR ) {
Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ function encryptMessageContent(messagePayload) {
7
7
return cipher . encrypt ( JSON . stringify ( messagePayload ) ) ;
8
8
}
9
9
10
- function decryptMessageContent ( messagePayload , messageHeaders ) {
11
- if ( ! messagePayload || messagePayload . toString ( ) . length === 0 ) {
12
- return null ;
10
+ function decryptMessageContent ( messagePayload ) {
11
+ if ( ! messagePayload || ! Buffer . isBuffer ( messagePayload ) ) {
12
+ throw new Error ( "Message payload supplied for decryption is either empty or not a Buffer" ) ;
13
13
}
14
14
try {
15
- return JSON . parse ( cipher . decrypt ( messagePayload . toString ( ) ) ) ;
15
+ return JSON . parse ( cipher . decrypt ( messagePayload ) ) ;
16
16
} catch ( err ) {
17
17
console . error ( err . stack ) ;
18
18
throw Error ( 'Failed to decrypt message: ' + err . message ) ;
You can’t perform that action at this time.
0 commit comments