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

net.zetetic.database.sqlcipher.SQLiteException: not authorized (code 1) #5

Open
wangtao7c0 opened this issue Sep 7, 2022 · 4 comments

Comments

@wangtao7c0
Copy link

lib: "net.zetetic:sqlcipher-android:4.5.2"
override fun postKey(connection: SQLiteConnection) {
connection.execute("SELECT load_extension('libsimple')", null, null)
}

when I run this code, my app is crashed by net.zetetic.database.sqlcipher.SQLiteException: not authorized (code 1)

pls give me some advice to address this, thks

I guess, is there some compile flags not enabled?

@developernotes
Copy link
Member

Hi @wangtao7c0

Are you using the Commercial, or Community edition of SQLCipher for Android? The former requires that you provide a license code prior to using any encryption operation. Providing the license code can be done in the preKey event of the SQLiteDatabaseHook via:

SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
  public void preKey(SQLiteConnection connection) {
    connection.executeForString(String.format("PRAGMA cipher_license = '%s';", LICENSE_CODE), new Object[]{}, null);
  }
  public void postKey(SQLiteConnection connection) {}
};

The Community edition does not utilize a runtime licensing mechanism.

@wangtao7c0
Copy link
Author

hi, I'm using the community edition.
connection.execute("SELECT load_extension('libsimple')", null, null)
is this operation must make in commercial edition?
is it possible to making it in community edition?

@developernotes
Copy link
Member

Hi @wangtao7c0

Both the Community and Commercial edition are built with -DSQLITE_ENABLE_LOAD_EXTENSION to allow for extension loading. Does SQLCipher behave properly if you remove your call to load_extension from the postKey event?

@wangtao7c0
Copy link
Author

wangtao7c0 commented Sep 13, 2022

Hi @developernotes

Yes, it work properly while removing the call to load_extension .

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