zeroshade commented on code in PR #1199:
URL: https://github.com/apache/arrow-adbc/pull/1199#discussion_r1358381338


##########
go/adbc/driver/snowflake/snowflake_database.go:
##########
@@ -328,13 +330,28 @@ func (d *databaseImpl) SetOptions(cnOptions 
map[string]string) error {
                                }
                        }
 
-                       d.cfg.PrivateKey, err = x509.ParsePKCS1PrivateKey(data)
+                       var block []byte
+                       if strings.Contains(string(data), "PRIVATE KEY") {
+                               b, _ := pem.Decode(data)
+                               block = b.Bytes
+                       } else {
+                               block = data
+                       }
+
+                       var key any
+                       key, err = x509.ParsePKCS1PrivateKey(block)
+                       if err != nil && strings.Contains(err.Error(), "use 
ParsePKCS8PrivateKey instead") {
+                               key, err = x509.ParsePKCS8PrivateKey(block)
+                       }
+                       
                        if err != nil {
                                return adbc.Error{
                                        Msg:  "failed parsing private key file 
'" + v + "': " + err.Error(),
                                        Code: adbc.StatusInvalidArgument,
                                }
                        }
+
+                       d.cfg.PrivateKey = key

Review Comment:
   You can't make this assign directly, you need to check that `key` is an 
`*rsa.PrivateKey` and type assert it. 
   
   While `ParsePKCS1PrivateKey` returns an `*rsa.PrivateKey`, 
`ParsePKCS8PrivateKey` might return an `*ecdsa.PrivateKey`, an 
`ed25519.PrivateKey` (not a pointer), or an `*ecdh.PrivateKey` (for X25519) 
while the Snowflake driver currently only accepts an `*rsa.PrivateKey` as far 
as I'm aware.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to