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

Error: Realm at path 'path/to/realm' already opened with a different encryption key. #2331

Closed
kenkotch opened this issue Apr 10, 2019 · 4 comments
Labels
O-Community T-Outdated Issue is likely not relevant anymore.

Comments

@kenkotch
Copy link

kenkotch commented Apr 10, 2019

Goals

read and write to encrypted realm

Expected Results

can encrypt, read and write

Actual Results

on android: Error: Realm at path 'path/to/realm' already opened with a different encryption key. (when trying to write)
on ios: Unable to open realm at path '': Realm file decryption failed Path:. (when building)

iOS:
Unable to open a realm at path '/Users/iguana/Library/Developer/CoreSimulator/Devices/116618B3-440A-4852-A412-B81CC062E752/data/Containers/Data/Application/504E3B95-597C-480B-A27A-F97136CC6E94/Documents/standardObject.realm': Realm file decryption failed Path:.

StandardObject.js:52:47 loadModuleImplementation require.js:331:6 index.js:1 loadModuleImplementation require.js:331:6 index.js:8 loadModuleImplementation require.js:331:6 Login.js:21 loadModuleImplementation require.js:331:6 RouterLogin.js:6 loadModuleImplementation require.js:331:6 App.js:4 loadModuleImplementation require.js:331:6 index.js:6 loadModuleImplementation require.js:331:6 guardedLoadModule require.js:197:45 global code :0 ![Simulator Screen Shot - iPhone X - 2019-04-10 at 15 35 59](https://user-images.githubusercontent.com/4110008/55915217-62b15b80-5ba6-11e9-94fe-6d9d1053227d.png)



Andriod:
Screenshot_1554926299

Steps to Reproduce

on ios, fails on build
on android fails on write to realm
both are solved when I remove the encryptionKey

Code Sample

const string = 'N60LgDmG4CuwC9Gb/qdgBvjR0bfRjN4NzPfRwmFj960//+EDlTSGpYwA1V83XDepAT+Dv/wFZL1cqvuIAZjbzw=='
const encryptionKey = base64js.toByteArray(string)

const standardObjectSchema = {
  path: 'standardObject.realm',
  schema: [standardObject, locationObject],
  schemaVersion: 0,
  encryptionKey
}

export const newStandardObject = new Realm(standardObjectSchema)

Version of Realm and Tooling

  • Realm JS SDK Version: ?
    "realm": "^2.26.0"
  • Node or React Native: ?
    "react": "16.8.3"
    "react-native": "0.59.3"
  • Client OS & Version: ?
    iOS: 12
    Android: 9
  • Which debugger for React Native: ?/None
    Flipper
@kenkotch
Copy link
Author

just made a new proj w/ realm. same issue: https://github.com/kenkotch/realmEncryptionTest

@kenkotch
Copy link
Author

kenkotch commented Apr 11, 2019

I handled the issue, though I would still like to know why the solution works.
Instead of adding the encryptionKey directly in standardObjectSchema, when I mount my first component where I import newStandardObject in componentDidMount, I add:
newStandardObject.encryptionKey = base64js.toByteArray(string)

nope. im wrong. that does not work. still getting the same error

@rajivshah3
Copy link
Contributor

Could this be related to realm/realm-core#3267?

@kenkotch
Copy link
Author

It may be. That project is long gone so I'm not actively looking into anymore

@bmunkholm bmunkholm added the T-Outdated Issue is likely not relevant anymore. label Jun 24, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
O-Community T-Outdated Issue is likely not relevant anymore.
Projects
None yet
Development

No branches or pull requests

3 participants