nakagami / firebirdsql

Firebird RDBMS sql driver for Go (golang)
MIT License
227 stars 60 forks source link

KeyHolderPlugin (Firebird3 or later) is not working #159

Closed k33pn3xtlvl closed 9 months ago

k33pn3xtlvl commented 9 months ago

After updating the Firebird from version 2.5 to version 3.0.8 I get the error message op_response:97. Unfortunately, due to my limited knowledge of golang, I am unable to determine from the source code how to solve the problem.

The update was triggered by an application using Firebird. As the application has no API, I call Firebird directly via this driver for some queries. For this reason, I do not want to make any firebird server-side adjustments. (For test purposes i can try to change it.)

Unfortunately, neither changing the auth_plugin_name nor the charset made any difference.

firebase.conf ```bash cat firebird.conf| grep -v '#\|^$' DefaultDbCachePages = 8K FileSystemCacheThreshold = 2M TempBlockSize = 2M TempCacheLimit = 128M KeyHolderPlugin = KeyHolder RemoteServicePort = 5145 RemoteAuxPort = 5146 LockMemSize = 2M LockHashSlots = 8191 ServerMode = Super ```
debug logs ```txt [c00014a480] opConnect [c00014a480] sendPackets():[0 0 0 1 0 0 0 19 0 0 0 3 0 0 0 1 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 8 0 0 1 77 9 6 83 89 83 68 66 65 8 6 83 114 112 50 53 54 10 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 7 255 0 55 100 51 98 55 50 57 57 51 48 54 97 54 56 49 99 48 57 53 49 48 97 56 48 56 49 49 57 53 51 52 56 56 48 97 54 98 101 54 52 49 101 97 98 52 52 52 102 50 48 99 101 53 54 55 100 57 54 54 98 53 97 50 101 102 101 102 50 56 97 56 48 54 52 100 99 98 50 57 98 97 56 51 100 56 102 55 52 97 57 100 55 56 51 101 51 101 102 52 100 49 57 101 55 53 56 53 48 102 50 98 98 52 99 100 99 97 100 53 54 99 52 56 100 50 50 55 100 97 50 56 57 102 49 52 52 100 98 52 97 97 57 57 101 55 53 52 98 50 97 100 56 50 50 57 98 50 100 54 50 100 101 49 50 50 57 52 102 97 99 54 53 53 102 50 100 56 97 52 97 100 52 52 57 97 55 98 50 99 56 48 99 100 57 50 54 98 53 97 53 50 99 52 101 53 99 101 100 52 102 102 48 56 49 56 52 54 102 56 98 55 56 102 101 101 102 101 100 57 53 50 102 52 98 101 101 48 50 55 48 97 50 54 53 97 48 55 48 97 101 99 48 57 54 7 3 1 55 51 11 4 1 0 0 0 1 11 107 51 51 112 110 51 120 116 108 118 108 4 8 82 76 76 76 65 83 48 53 6 0 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 2 255 255 128 11 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 4 255 255 128 12 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 6 255 255 128 13 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 8 255 255 128 14 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 10 255 255 128 15 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 12 255 255 128 16 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 14 255 255 128 17 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 16] [c00014a480] _parse_connect_response [c00014a480] recvPackets():[0 0 0 98]: [c00014a480] recvPackets():[255 255 128 15 0 0 0 1 0 0 0 5]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] recvPackets():[0 0 0 3]: [c00014a480] recvPackets():[83 114 112 0]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] opContAuth [c00014a480] sendPackets():[0 0 0 92 0 0 1 0 55 100 51 98 55 50 57 57 51 48 54 97 54 56 49 99 48 57 53 49 48 97 56 48 56 49 49 57 53 51 52 56 56 48 97 54 98 101 54 52 49 101 97 98 52 52 52 102 50 48 99 101 53 54 55 100 57 54 54 98 53 97 50 101 102 101 102 50 56 97 56 48 54 52 100 99 98 50 57 98 97 56 51 100 56 102 55 52 97 57 100 55 56 51 101 51 101 102 52 100 49 57 101 55 53 56 53 48 102 50 98 98 52 99 100 99 97 100 53 54 99 52 56 100 50 50 55 100 97 50 56 57 102 49 52 52 100 98 52 97 97 57 57 101 55 53 52 98 50 97 100 56 50 50 57 98 50 100 54 50 100 101 49 50 50 57 52 102 97 99 54 53 53 102 50 100 56 97 52 97 100 52 52 57 97 55 98 50 99 56 48 99 100 57 50 54 98 53 97 53 50 99 52 101 53 99 101 100 52 102 102 48 56 49 56 52 54 102 56 98 55 56 102 101 101 102 101 100 57 53 50 102 52 98 101 101 48 50 55 48 97 50 54 53 97 48 55 48 97 101 99 48 57 54 55 51 0 0 0 3 83 114 112 0 0 0 0 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 0 0 0 0 0 0] [c00014a480] recvPackets():[0 0 0 92]: [c00014a480] recvPackets():[0 0 1 67]: [c00014a480] recvPackets():[64 0 68 68 49 68 53 68 49 70 48 70 54 68 55 70 68 65 66 57 69 48 54 70 55 68 55 54 52 48 48 69 50 66 54 56 53 67 57 53 51 55 49 51 53 66 56 57 55 66 65 57 53 48 69 54 54 68 56 56 52 66 70 57 67 56 255 0 65 48 57 54 50 52 49 69 56 49 65 57 51 67 52 49 52 52 54 52 66 69 55 56 52 53 56 48 69 50 56 48 53 50 49 65 57 57 70 70 70 57 49 49 69 68 57 70 54 69 66 50 55 66 54 69 65 57 54 56 68 69 53 56 53 69 70 55 68 49 68 68 50 52 56 51 49 65 53 69 70 57 68 52 65 53 66 67 49 48 49 49 51 52 56 70 50 55 48 49 67 48 53 69 69 67 69 48 53 70 65 65 52 50 48 51 53 65 70 57 49 52 49 48 50 70 53 50 55 70 48 68 57 50 52 53 52 70 51 51 51 54 56 69 69 52 49 68 68 50 54 67 67 50 55 54 56 54 66 70 48 55 57 51 53 53 48 70 52 67 56 50 54 67 51 68 56 53 56 70 51 68 49 57 65 54 66 50 65 53 51 70 67 49 66 66 70 48 69 65 66 55 53 57 51 65 67 70 48 51 51 68 48 70 53 56 50 68 51 48 69 65 49 54 48 49 50 57 53 51 49 56 56 54 55 69 70 54 68 55 50 65 67 49 68 50 65 49 51 66 70 68 67 53 65 0]: [c00014a480] recvPackets():[0 0 0 3]: [c00014a480] recvPackets():[83 114 112 0]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] opContAuth [c00014a480] sendPackets():[0 0 0 92 0 0 0 40 55 55 100 50 55 49 97 50 101 52 55 56 100 101 48 48 49 52 100 49 98 98 102 57 97 97 52 52 50 100 55 56 99 50 50 51 48 50 57 49 0 0 0 6 83 114 112 50 53 54 0 0 0 0 0 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 0 0 0 0 0 0] [c00014a480] opResponse [c00014a480] recvPackets():[0 0 0 9]: [c00014a480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17]: [c00014a480] recvPackets():[0 9 83 121 109 109 101 116 114 105 99 1 4 65 114 99 52 0 0 0]: [c00014a480] recvPackets():[0 0 0 1]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] sendPackets():[0 0 0 96 0 0 0 4 65 114 99 52 0 0 0 9 83 121 109 109 101 116 114 105 99 0 0 0] [c00014a480] opResponse [c00014a480] recvPackets():[0 0 0 9]: [c00014a480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] recvPackets():[0 0 0 1]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] opAttach [c00014a480] sendPackets():[0 0 0 19 0 0 0 0 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 92 1 63 4 3 0 0 0 48 4 85 84 70 56 28 6 83 89 83 68 66 65 29 9 109 97 115 116 101 114 107 101 121 60 9 82 68 66 36 65 68 77 73 78 71 4 107 42 23 0 74 38 47 116 109 112 47 103 111 45 98 117 105 108 100 50 54 57 48 53 55 50 52 49 51 47 98 48 48 49 47 101 120 101 47 116 101 115 116 50 77 1 1] [c00014a480] opResponse [c00014a480] recvPackets():[0 0 0 97]: ```

Here is my example code which results the same error (it is almost the same as in issue #151)

go code ```go package main import ( "fmt" "log" "time" "github.com/jmoiron/sqlx" _ "github.com/nakagami/firebirdsql" ) func main() { err := dbConTest() if err != nil { log.Fatal(err) } fmt.Println("DONE") } func dbConTest() error { dsn := "SYSDBA:masterkey@192.168.58.201:5145/C:\\Users\\Home\\Desktop\\DB\\DB.FDB?role=RDB$ADMIN" log.Println("dsn", dsn) db, err := sqlx.Open("firebirdsql", dsn) if err != nil { return err } log.Println("db", db) db.SetMaxOpenConns(10) db.SetMaxIdleConns(10) db.SetConnMaxLifetime(5 * time.Minute) err = db.Ping() // <- returns Error op_response:97 if err != nil { return err } return nil } ```
nakagami commented 9 months ago

Thank you very much. Your logs are very helpful.

If the code listed above does not have a Ping(), will the subsequent Query work?

And one more thing, does it give an error if you give the following settings in firebird.conf?

AuthServer = Srp256,Srp,Legacy_Auth

Trying to figure out if the problem is with Ping() or authentication.

k33pn3xtlvl commented 9 months ago

Thank you, I have implemented your instructions, here are my results and attempts.

I'm not sure how much this attitude plays a role, but this is the output of the keyholder.conf

type .\plugins\KeyHolder.conf

UnsafeClient=true

Add in firebird.conf AuthServer = Srp256,Srp,Legacy_Auth

main.go ```go func main() { err := dbConTest() if err != nil { log.Fatal(err) } fmt.Println("DONE") } func dbConTest() error { authMethod := "Srp256" dsn := "SYSDBA:masterkey@192.168.58.201:5145/C:\\Users\\Home\\Desktop\\DB\\DB.FDB?role=RDB$ADMIN&auth_plugin_name=" + authMethod log.Println("dsn", dsn) db, err := sqlx.Open("firebirdsql", dsn) if err != nil { return fmt.Errorf("db open error: %q", err) } log.Println("db", db) rows, err := db.Query("SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database;") if err != nil { return fmt.Errorf("db query error: %q", err) } fmt.Println(rows) // db.SetMaxOpenConns(10) // db.SetMaxIdleConns(10) // db.SetConnMaxLifetime(5 * time.Minute) // err = db.Ping() // <- returns Error op_response:97 // if err != nil { // return err // } return nil } ```
go run output ```txt 2023/12/22 10:14:16 dsn SYSDBA:masterkey@192.168.58.201:5145/C:\Users\Home\Desktop\DB\DB.FDB?role=RDB$ADMIN&auth_plugin_name=Srp256 2023/12/22 10:14:16 db &{0xc0000b7a00 firebirdsql false 0xc0000b4600} [c0000d4480] opConnect [c0000d4480] sendPackets():[0 0 0 1 0 0 0 19 0 0 0 3 0 0 0 1 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 8 0 0 1 77 9 6 83 89 83 68 66 65 8 6 83 114 112 50 53 54 10 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 7 255 0 50 53 97 102 102 52 51 52 51 49 48 54 98 52 102 98 49 51 98 49 51 51 102 53 53 48 52 98 51 49 54 57 52 48 54 49 57 100 48 97 50 52 52 52 55 53 56 98 57 100 52 52 99 100 51 56 51 99 100 52 48 100 51 100 55 57 54 53 98 50 54 101 101 48 101 49 99 51 57 52 55 100 99 98 100 50 100 97 53 100 97 51 56 51 56 52 48 102 52 56 97 50 97 99 50 97 48 54 101 51 97 57 55 99 56 98 98 98 98 102 56 56 48 56 57 51 49 49 99 99 54 48 53 56 51 98 56 50 49 54 56 97 50 55 100 99 49 50 55 51 49 49 100 99 49 98 54 56 101 56 48 102 50 48 49 49 102 50 55 54 99 97 48 55 97 54 48 57 53 97 99 102 50 99 98 98 52 52 55 56 56 98 56 101 54 48 54 54 56 50 49 98 49 52 55 57 50 49 50 48 57 53 100 54 50 52 55 98 52 54 97 101 102 51 101 52 53 99 55 53 53 55 56 102 48 49 50 54 51 51 53 102 99 97 51 98 50 97 49 100 101 98 55 99 7 3 1 57 50 11 4 1 0 0 0 1 11 107 51 51 112 110 51 120 116 108 118 108 4 8 82 76 76 76 65 83 48 53 6 0 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 2 255 255 128 11 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 4 255 255 128 12 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 6 255 255 128 13 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 8 255 255 128 14 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 10 255 255 128 15 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 12 255 255 128 16 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 14 255 255 128 17 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 16] [c0000d4480] _parse_connect_response [c0000d4480] recvPackets():[0 0 0 98]: [c0000d4480] recvPackets():[255 255 128 15 0 0 0 1 0 0 0 5]: [c0000d4480] recvPackets():[0 0 1 68]: [c0000d4480] recvPackets():[64 0 68 68 49 68 53 68 49 70 48 70 54 68 55 70 68 65 66 57 69 48 54 70 55 68 55 54 52 48 48 69 50 66 54 56 53 67 57 53 51 55 49 51 53 66 56 57 55 66 65 57 53 48 69 54 54 68 56 56 52 66 70 57 67 56 0 1 49 69 57 50 67 49 65 66 51 68 65 70 66 50 65 66 51 66 49 50 69 54 57 56 53 56 48 52 67 69 67 69 69 70 68 57 48 55 66 50 52 70 54 48 57 67 68 50 55 65 51 55 67 69 52 50 67 50 49 56 50 52 50 56 49 70 66 55 50 55 66 54 65 70 67 57 68 56 51 57 50 66 70 48 68 57 66 56 52 52 56 66 70 48 55 55 49 67 49 52 55 53 66 65 48 53 49 48 53 54 53 68 54 49 57 66 53 68 51 50 50 50 56 54 68 52 65 50 54 57 67 55 57 53 65 50 49 51 48 48 55 50 51 70 65 70 56 68 49 68 48 55 56 53 69 68 48 52 55 55 57 55 51 57 70 48 70 53 68 49 54 50 54 57 69 50 53 49 49 68 56 57 49 55 53 65 51 55 48 50 65 50 51 68 69 56 51 49 48 56 66 67 49 69 56 66 55 68 48 56 48 69 56 53 66 52 49 69 51 67 65 67 67 67 65 55 70 66 49 49 51 54 55 56 55 48 67 69 65 70 53 67 54 57 68 55 54 48 67 65 68 66 49 67 56 68]: [c0000d4480] recvPackets():[0 0 0 6]: [c0000d4480] recvPackets():[83 114 112 50 53 54 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] opContAuth [c0000d4480] sendPackets():[0 0 0 92 0 0 0 64 54 50 97 100 49 98 57 51 53 102 48 56 101 49 48 51 102 51 52 55 55 57 98 48 54 57 99 53 50 50 54 50 53 100 100 57 48 49 100 100 52 57 53 100 52 49 101 98 57 51 50 54 100 53 48 99 55 98 97 57 100 56 99 100 0 0 0 6 83 114 112 50 53 54 0 0 0 0 0 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 0 0 0 0 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17]: [c0000d4480] recvPackets():[0 9 83 121 109 109 101 116 114 105 99 1 4 65 114 99 52 0 0 0]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] sendPackets():[0 0 0 96 0 0 0 4 65 114 99 52 0 0 0 9 83 121 109 109 101 116 114 105 99 0 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] opAttach [c0000d4480] sendPackets():[0 0 0 19 0 0 0 0 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 92 1 63 4 3 0 0 0 48 4 85 84 70 56 28 6 83 89 83 68 66 65 29 9 109 97 115 116 101 114 107 101 121 60 9 82 68 66 36 65 68 77 73 78 71 4 35 170 2 0 74 38 47 116 109 112 47 103 111 45 98 117 105 108 100 49 50 53 53 50 56 50 54 57 57 47 98 48 48 49 47 101 120 101 47 116 101 115 116 50 77 1 1] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 97]: 2023/12/22 10:14:16 db query error: "Error op_response:97" exit status 1 ```

Results:

dsn := "SYSDBA:masterkey@192.168.58.201:5145/C:\Users\Home\Desktop\DB\DB.FDB?role=RDB$ADMIN&auth_plugin_name=Legacy_Auth" "Client attempted to attach unencrypted but wire encryption is required"

debug logs ```txt [c00014a480] opConnect [c00014a480] sendPackets():[0 0 0 1 0 0 0 19 0 0 0 3 0 0 0 1 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 8 0 0 0 90 9 6 83 89 83 68 66 65 8 11 76 101 103 97 99 121 95 65 117 116 104 10 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 7 12 0 81 80 51 76 77 90 47 77 74 104 46 11 4 1 0 0 0 1 11 107 51 51 112 110 51 120 116 108 118 108 4 8 82 76 76 76 65 83 48 53 6 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 2 255 255 128 11 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 4 255 255 128 12 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 6 255 255 128 13 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 8 255 255 128 14 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 10 255 255 128 15 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 12 255 255 128 16 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 14 255 255 128 17 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 16] [c00014a480] _parse_connect_response [c00014a480] recvPackets():[0 0 0 94]: [c00014a480] recvPackets():[255 255 128 15 0 0 0 1 0 0 0 5]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] recvPackets():[0 0 0 1]: [c00014a480] recvPackets():[0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] opAttach [c00014a480] sendPackets():[0 0 0 19 0 0 0 0 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 92 1 63 4 3 0 0 0 48 4 85 84 70 56 28 6 83 89 83 68 66 65 29 9 109 97 115 116 101 114 107 101 121 60 9 82 68 66 36 65 68 77 73 78 71 4 148 119 2 0 74 38 47 116 109 112 47 103 111 45 98 117 105 108 100 51 52 55 54 49 50 57 50 55 52 47 98 48 48 49 47 101 120 101 47 116 101 115 116 50 77 1 1] [c00014a480] opResponse [c00014a480] recvPackets():[0 0 0 9]: [c00014a480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]: [c00014a480] recvPackets():[]: [c00014a480] recvPackets():[0 0 0 1]: [c00014a480] recvPackets():[20 0 2 233]: [c00014a480] recvPackets():[0 0 0 0]: ```

dsn := "SYSDBA:masterkey@192.168.58.201:5145/C:\Users\Home\Desktop\DB\DB.FDB?role=RDB$ADMIN&wire_crypt=true&auth_plugin_name=Legacy_Auth" "Client attempted to attach unencrypted but wire encryption is required"

debug logs ```txt [c0000d4480] opConnect [c0000d4480] sendPackets():[0 0 0 1 0 0 0 19 0 0 0 3 0 0 0 1 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 8 0 0 0 90 9 6 83 89 83 68 66 65 8 11 76 101 103 97 99 121 95 65 117 116 104 10 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 7 12 0 81 80 51 76 77 90 47 77 74 104 46 11 4 1 0 0 0 1 11 107 51 51 112 110 51 120 116 108 118 108 4 8 82 76 76 76 65 83 48 53 6 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 2 255 255 128 11 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 4 255 255 128 12 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 6 255 255 128 13 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 8 255 255 128 14 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 10 255 255 128 15 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 12 255 255 128 16 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 14 255 255 128 17 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 16] [c0000d4480] _parse_connect_response [c0000d4480] recvPackets():[0 0 0 94]: [c0000d4480] recvPackets():[255 255 128 15 0 0 0 1 0 0 0 5]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] opAttach [c0000d4480] sendPackets():[0 0 0 19 0 0 0 0 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 90 1 63 4 3 0 0 0 48 4 85 84 70 56 28 6 83 89 83 68 66 65 29 9 109 97 115 116 101 114 107 101 121 60 9 82 68 66 36 65 68 77 73 78 71 4 44 112 2 0 74 36 47 116 109 112 47 103 111 45 98 117 105 108 100 51 52 54 53 50 51 52 56 47 98 48 48 49 47 101 120 101 47 116 101 115 116 50 77 1 1 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[20 0 2 233]: [c0000d4480] recvPackets():[0 0 0 0]: ```

dsn := "SYSDBA:masterkey@192.168.58.201:5145/C:\Users\Home\Desktop\DB\DB.FDB?role=RDB$ADMIN&auth_plugin_name=Srp256" Error op_response:97

debug logs ```txt [c0000d4480] opConnect [c0000d4480] sendPackets():[0 0 0 1 0 0 0 19 0 0 0 3 0 0 0 1 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 8 0 0 1 77 9 6 83 89 83 68 66 65 8 6 83 114 112 50 53 54 10 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 7 255 0 98 56 100 50 56 97 51 48 99 54 97 54 51 100 57 49 49 50 49 53 57 50 101 99 51 98 97 55 49 54 52 97 51 55 51 57 53 98 49 54 101 100 100 100 102 54 48 98 52 100 49 101 57 48 97 53 48 55 99 101 56 51 102 97 49 99 98 53 102 55 55 97 57 55 51 55 101 101 102 55 101 55 98 49 49 50 99 51 54 100 101 102 98 57 49 51 99 56 101 57 55 97 97 99 55 102 48 56 51 57 53 55 53 102 99 99 99 54 53 53 98 49 98 100 100 97 100 55 102 56 52 98 102 49 98 52 102 57 53 57 56 55 57 55 56 97 50 97 54 56 53 98 56 49 102 97 99 51 57 98 49 100 100 101 50 102 101 100 54 55 98 48 54 50 50 101 54 53 101 102 57 52 52 100 55 51 50 100 99 55 52 53 48 53 52 53 53 100 100 97 98 48 50 48 99 97 50 102 50 52 102 52 54 55 56 49 50 49 100 100 51 48 50 100 48 97 50 53 101 50 102 56 52 100 54 50 53 54 99 54 53 97 98 57 57 52 54 100 101 57 55 55 55 97 7 3 1 99 102 11 4 1 0 0 0 1 11 107 51 51 112 110 51 120 116 108 118 108 4 8 82 76 76 76 65 83 48 53 6 0 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 2 255 255 128 11 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 4 255 255 128 12 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 6 255 255 128 13 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 8 255 255 128 14 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 10 255 255 128 15 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 12 255 255 128 16 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 14 255 255 128 17 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 16] [c0000d4480] _parse_connect_response [c0000d4480] recvPackets():[0 0 0 98]: [c0000d4480] recvPackets():[255 255 128 15 0 0 0 1 0 0 0 5]: [c0000d4480] recvPackets():[0 0 1 68]: [c0000d4480] recvPackets():[64 0 68 68 49 68 53 68 49 70 48 70 54 68 55 70 68 65 66 57 69 48 54 70 55 68 55 54 52 48 48 69 50 66 54 56 53 67 57 53 51 55 49 51 53 66 56 57 55 66 65 57 53 48 69 54 54 68 56 56 52 66 70 57 67 56 0 1 51 70 69 55 50 48 65 57 67 69 51 51 52 52 51 49 69 49 55 69 51 54 51 55 57 68 51 48 49 52 53 57 55 67 55 67 48 48 50 67 49 55 66 57 51 53 54 65 54 70 65 65 66 70 68 65 67 57 49 55 55 48 69 56 56 54 48 48 49 67 51 50 55 65 57 70 67 50 57 54 70 55 49 68 48 52 50 69 50 57 56 54 65 49 57 67 55 56 51 67 56 69 49 67 48 51 65 56 51 56 70 70 49 55 50 65 53 48 53 48 55 54 54 51 52 48 55 49 52 51 51 53 55 68 48 50 52 68 65 55 55 68 52 49 57 54 52 52 66 65 51 65 56 57 66 67 50 69 67 48 68 51 66 69 68 50 53 53 69 53 53 54 50 51 52 49 54 69 48 66 53 66 52 54 68 52 48 54 52 54 56 49 67 49 53 56 52 67 54 68 68 66 48 50 57 51 68 69 48 70 54 69 56 55 53 49 54 53 66 48 55 52 67 51 68 70 56 54 69 54 52 68 51 68 69 67 68 49 66 50 68 51 67 56 48 57 56 55 67 48 70 51 70 67 67 57]: [c0000d4480] recvPackets():[0 0 0 6]: [c0000d4480] recvPackets():[83 114 112 50 53 54 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] opContAuth [c0000d4480] sendPackets():[0 0 0 92 0 0 0 64 50 49 50 53 102 101 56 51 57 55 57 97 54 99 101 52 53 55 99 100 102 55 55 53 100 50 56 49 100 57 49 56 97 100 48 100 56 50 99 56 51 101 97 54 48 51 102 52 55 101 50 101 49 101 99 99 53 55 102 99 48 48 55 53 0 0 0 6 83 114 112 50 53 54 0 0 0 0 0 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 0 0 0 0 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17]: [c0000d4480] recvPackets():[0 9 83 121 109 109 101 116 114 105 99 1 4 65 114 99 52 0 0 0]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] sendPackets():[0 0 0 96 0 0 0 4 65 114 99 52 0 0 0 9 83 121 109 109 101 116 114 105 99 0 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] opAttach [c0000d4480] sendPackets():[0 0 0 19 0 0 0 0 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 92 1 63 4 3 0 0 0 48 4 85 84 70 56 28 6 83 89 83 68 66 65 29 9 109 97 115 116 101 114 107 101 121 60 9 82 68 66 36 65 68 77 73 78 71 4 231 134 2 0 74 38 47 116 109 112 47 103 111 45 98 117 105 108 100 49 51 54 50 51 57 49 48 54 57 47 98 48 48 49 47 101 120 101 47 116 101 115 116 50 77 1 1] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 97]: ```

dsn := "SYSDBA:masterkey@192.168.58.201:5145/C:\Users\Home\Desktop\DB\DB.FDB?role=RDB$ADMIN&auth_plugin_name=Srp" Error op_response:97

debug logs ```txt [c0000d4480] opConnect [c0000d4480] sendPackets():[0 0 0 1 0 0 0 19 0 0 0 3 0 0 0 1 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 8 0 0 1 74 9 6 83 89 83 68 66 65 8 3 83 114 112 10 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 7 255 0 100 50 98 56 99 55 53 51 48 54 102 55 55 49 49 48 55 101 49 52 54 98 50 101 50 52 101 100 99 53 100 53 55 99 54 51 97 50 56 49 49 100 48 55 48 100 100 101 98 101 55 56 53 48 48 98 55 100 50 54 53 102 100 99 56 50 99 52 50 49 50 97 55 53 50 57 54 102 48 54 100 98 51 99 102 50 51 48 99 53 100 50 56 54 100 54 102 97 98 50 54 52 52 50 97 99 48 55 51 98 56 57 57 99 97 50 100 97 100 101 100 48 53 102 99 57 52 98 101 57 54 100 55 55 98 50 55 101 57 51 50 52 57 57 55 54 54 57 56 48 100 55 99 56 57 102 49 101 50 51 57 99 55 50 57 51 101 100 57 97 54 49 102 48 101 98 56 98 56 54 56 54 54 49 50 55 49 56 50 52 52 97 49 98 57 57 98 51 51 54 50 51 100 57 101 52 56 102 101 99 48 50 53 52 52 99 56 49 55 97 57 99 55 56 55 102 57 48 99 49 57 98 48 49 49 51 99 56 55 102 57 99 97 101 54 51 53 57 97 49 98 50 55 50 7 3 1 101 98 11 4 1 0 0 0 1 11 107 51 51 112 110 51 120 116 108 118 108 4 8 82 76 76 76 65 83 48 53 6 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 2 255 255 128 11 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 4 255 255 128 12 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 6 255 255 128 13 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 8 255 255 128 14 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 10 255 255 128 15 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 12 255 255 128 16 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 14 255 255 128 17 0 0 0 1 0 0 0 0 0 0 0 5 0 0 0 16] [c0000d4480] _parse_connect_response [c0000d4480] recvPackets():[0 0 0 98]: [c0000d4480] recvPackets():[255 255 128 15 0 0 0 1 0 0 0 5]: [c0000d4480] recvPackets():[0 0 1 68]: [c0000d4480] recvPackets():[64 0 68 68 49 68 53 68 49 70 48 70 54 68 55 70 68 65 66 57 69 48 54 70 55 68 55 54 52 48 48 69 50 66 54 56 53 67 57 53 51 55 49 51 53 66 56 57 55 66 65 57 53 48 69 54 54 68 56 56 52 66 70 57 67 56 0 1 57 66 53 57 54 68 65 50 56 52 56 49 53 52 48 56 57 54 56 65 54 52 50 55 67 55 53 66 68 49 49 68 66 52 53 49 66 48 48 67 53 48 48 57 52 49 55 52 51 48 52 67 70 55 53 54 57 53 68 52 53 68 56 68 49 50 70 51 65 65 54 69 66 53 50 66 69 67 65 66 70 57 49 70 68 51 51 50 68 49 68 51 70 68 53 49 70 67 68 52 56 52 57 53 65 57 54 57 48 53 57 53 48 48 50 51 67 53 69 56 68 55 65 70 56 67 67 68 53 50 66 70 68 69 66 51 54 48 57 55 67 51 66 51 69 68 51 53 51 48 70 57 48 56 55 51 70 67 48 67 48 70 53 57 65 68 52 54 53 70 69 67 48 65 56 51 65 48 49 51 65 48 57 69 65 50 56 52 70 53 66 66 53 52 65 52 57 70 49 54 68 69 50 57 49 55 69 69 65 70 56 65 69 54 69 48 65 68 52 52 53 48 57 54 67 66 70 66 66 67 65 54 65 67 69 48 57 66 69 68 54 50 49 51 49 52 53 70 55 69 53 54 69 52 52 70]: [c0000d4480] recvPackets():[0 0 0 3]: [c0000d4480] recvPackets():[83 114 112 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] opContAuth [c0000d4480] sendPackets():[0 0 0 92 0 0 0 40 54 99 101 56 48 100 56 98 97 50 51 97 97 97 98 54 49 51 48 56 52 100 52 101 56 102 101 52 57 100 99 51 49 52 97 100 101 57 54 102 0 0 0 3 83 114 112 0 0 0 0 22 83 114 112 50 53 54 44 83 114 112 44 76 101 103 97 99 121 95 65 117 116 104 0 0 0 0 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17]: [c0000d4480] recvPackets():[0 9 83 121 109 109 101 116 114 105 99 1 4 65 114 99 52 0 0 0]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] sendPackets():[0 0 0 96 0 0 0 4 65 114 99 52 0 0 0 9 83 121 109 109 101 116 114 105 99 0 0 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 9]: [c0000d4480] recvPackets():[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]: [c0000d4480] recvPackets():[]: [c0000d4480] recvPackets():[0 0 0 1]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] recvPackets():[0 0 0 0]: [c0000d4480] opAttach [c0000d4480] sendPackets():[0 0 0 19 0 0 0 0 0 0 0 31 67 58 92 85 115 101 114 115 92 72 111 109 101 92 68 101 115 107 116 111 112 92 68 66 92 68 66 46 70 68 66 0 0 0 0 91 1 63 4 3 0 0 0 48 4 85 84 70 56 28 6 83 89 83 68 66 65 29 9 109 97 115 116 101 114 107 101 121 60 9 82 68 66 36 65 68 77 73 78 71 4 201 127 2 0 74 37 47 116 109 112 47 103 111 45 98 117 105 108 100 54 50 50 54 50 56 52 48 49 47 98 48 48 49 47 101 120 101 47 116 101 115 116 50 77 1 1 0] [c0000d4480] opResponse [c0000d4480] recvPackets():[0 0 0 97]: ```
nakagami commented 9 months ago

I see, it seems that the authentication is failing, not Ping().

The gsec results in my environment look like this

$ /opt/firebird/bin/gsec -display -user sysdba -password masterkey
     user name                    uid   gid admin     full name
------------------------------------------------------------------------------------------------
SYSDBA

I am building Firebird Server from the latest source code, so what you see may be different, but do you have a SYSDBA user? Also, can you connect with isql with the same user and password as the code?

I have only been able to test on Ubuntu, but I don't think I have received similar reports on Windows.

Has anyone solved the same situation with the same environment Firebird 3.0.8 + Windows?

k33pn3xtlvl commented 9 months ago

Many thanks for the very quick reply! - Yes the user exists in the db.

Here are my results, there are a few other users, but I think this user is the relevant one.

.\gsec.exe -display -user sysdba -password masterkey
     user name                    uid   gid admin     full name
------------------------------------------------------------------------------------------------
SYSDBA                              0     0

As an example, I can establish a clean connection with firebird via dbeaver ce (v23.3.0) or via falmerobin (0.9.10 (git hash f4386f82) Unicode).


A small side note that may also be helpful for this and your other project As you also develop "https://github.com/nakagami/pyfirebirdsql" I tested in container "jacobalberty/firebird:v3.0.8" with the pyfirebirdsql driver to be make sure it was not my fault in some way or the installed Firebird 3.0.8 on Windows. I also tried the latest "https://pypi.org/project/fdb/".

Unfortunately I got the same error with the pyfirebirdsql driver:

swappy-20231222-125707

But it works with the python3 "fdb" swappy-20231222-124929

nakagami commented 9 months ago

Maybe KeyHolderPlugin is not working. I have never used it.

k33pn3xtlvl commented 9 months ago

After some long debugging and reverse sessions and seeing how it is implemented in C# (https://github.com/FirebirdSQL/NETProvider/blob/87933e5e9edb79dcab32f410431c407cd8219b10/src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/GdsDatabase.cs#L297 and https://github.com/FirebirdSQL/NETProvider/blob/87933e5e9edb79dcab32f410431c407cd8219b10/src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/GdsDatabase.cs#L49), I was able to get it to work. Since I currently (at least for now) do not need to provide a decryption key, I would leave this implementation as it is, as it covers my needs and maybe someone else's as well. As I am not a developer, do you have any objections or suggestions? Or should I just make a merge request?

This is my diff

diff --git a/wireprotocol.go b/wireprotocol.go
index f858306..6f73dfd 100644
--- a/wireprotocol.go
+++ b/wireprotocol.go
@@ -33,15 +33,16 @@ import (
    "encoding/hex"
    "errors"
    "fmt"
-   "github.com/kardianos/osext"
-   "gitlab.com/nyarla/go-crypt"
-   "golang.org/x/crypto/chacha20"
    "math/big"
    "net"
    "os"
    "strconv"
    "strings"
    "time"
+
+   "github.com/kardianos/osext"
+   "gitlab.com/nyarla/go-crypt"
+   "golang.org/x/crypto/chacha20"
    //"unsafe"
 )

@@ -864,6 +865,15 @@ func (p *wireProtocol) opCrypt(plugin string) error {
    return err
 }

+func (p *wireProtocol) opCryptCallback() error {
+   p.debugPrint("opCryptCallback")
+   p.packInt(op_crypt_key_callback)
+   p.packInt(0)
+   p.packInt(int32(BUFFER_LEN))
+   _, err := p.sendPackets()
+   return err
+}
+
 func (p *wireProtocol) opDropDatabase() error {
    p.debugPrint("opDropDatabase")
    p.packInt(op_drop_database)
@@ -1216,6 +1226,17 @@ func (p *wireProtocol) opResponse() (int32, []byte, []byte, error) {
    for bytes_to_bint32(b) == op_dummy {
        b, _ = p.recvPackets(4)
    }
+   for bytes_to_bint32(b) == op_crypt_key_callback {
+
+       err = p.opCryptCallback()
+       if err != nil {
+           return 0, nil, nil, err
+       }
+
+       b, _ = p.recvPackets(12)
+       b, _ = p.recvPackets(4)
+
+   }
    for bytes_to_bint32(b) == op_response && p.lazyResponseCount > 0 {
        p.lazyResponseCount--
        _, _, _, _ = p._parse_op_response()
nakagami commented 9 months ago

Thanks, this modifications are seems good.

format code as

gofmt -w *.go

and then, please send the Pull Request. I will merge it.

nakagami commented 9 months ago

thanks