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

Encrypt and Decrypt are not compatible between OSX and Windows OS. #11

Open
voiceactivity opened this issue Jul 12, 2018 · 3 comments
Open

Comments

@voiceactivity
Copy link

voiceactivity commented Jul 12, 2018

How to reproduce:

  1. Execute on OSX: sls encrypt -s stag --password 'xxx'

  2. Commit to git secrets.prod.yml.encrypted.

  3. Make git pull of the same file on Win10.

  4. Execute on Win10: sls decrypt -s stag --password 'xxx'

  5. Error:
    Error --------------------------------------------------
    error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
    For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
    Get Support --------------------------------------------
    Docs: docs.serverless.com
    Bugs: github.com/serverless/serverless/issues
    Issues: forum.serverless.com
    Your Environment Information -----------------------------
    OS: win32
    Node Version: 8.9.1
    Serverless Version: 1.28.0

  6. File unreadable.
    Note: the passwords used are correct. I double checked and the encrypt|decrypt still work on my Mac (where I initially encrypted files).

@voiceactivity
Copy link
Author

Just finished another test in reversed order:

  1. Encrypt on Win10
  2. Git push.
  3. Git pull on OSX
  4. Decrypt on OSX failed with the same error.
    Password was correct! :-)

@QAnders
Copy link

QAnders commented Mar 19, 2019

We are experiencing the same issue now in our team, MAC encrypt can't be decrypted on Windows 10 (neither Win10 native sls not Win10 subsystem linux (Ubuntu)).

@QAnders
Copy link

QAnders commented Apr 18, 2019

I did a "quick-fix" as I can't figure out where the inconsistency comes from...
I couldn't open a Pull Request, so here we go:

package.js: + line 37: "stream-replace": "^1.0.0"

index.js:

  • line 7: const replace = require('stream-replace');
    line 92: .pipe(crypto.createDecipher(algorithm, this.options.password).setAutoPadding(false))
  • line 94: .pipe(replace(/\4/g, ''))
  • line 95: .on('error', reject)

I've added stream-replace to the project and setting .setAutoPadding(false) in decrypt() function.
As there still is an issue with four EOT characters (char hex: 04) appearing as the last four characters in the decrypted data I replace them with empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants