mutecomm / go-sqlcipher

Self-contained Go sqlite3 driver with an AES-256 encrypted sqlite3 database
Other
159 stars 60 forks source link

Database re-encrypts after a minute or so #6

Closed cpacia closed 5 years ago

cpacia commented 6 years ago

Question.

I'm currently doing something like this:

conn, err := sql.Open("sqlite3", dbPath)
if err != nil {
    return nil, err
}
if password != "" {
    p := "pragma key='" + password + "';"
    conn.Exec(p)
}

Immediately following this code I query to check to see if the db decrypted properly and it does. But then a minute or so later I start getting a file is encrypted or is not a database error. I'm not closing the connection. Just making queries on the existing instance.

Am I using this wrong? Is there some kind of timeout that re-encrypts it shortly after decryption? Do I need to re-call pragma key= before each db query?

frankbraun commented 6 years ago

No, that should be fine. Please compare your code to the examples in https://github.com/mutecomm/go-sqlcipher/blob/master/sqlcipher_test.go

Do you use "database/sql" or do you use another abstraction layer on top that might open up a separate connection which is then not decrypted?

If possible, could you create a minimal example (like the ones in the test file) that reproduces your problem? I have never seen your problem and I have no idea how I would go about reproducing it.

frankbraun commented 5 years ago

Since I didn't hear back I'm closing this issue. Please reopen if the problem is reproducible.