You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/21 01:24:23 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue, #23003: ERROR: Input byte array has incorrect ending byte at 24 occurs when I config encrypt rule on PostgreSQL/openGauss char type column

strongduanmu opened a new issue, #23003:
URL: https://github.com/apache/shardingsphere/issues/23003

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   [11f19c4](https://github.com/apache/shardingsphere/commit/11f19c41de1886ecbdf8f3ea423b478ac6c171cd)
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-Proxy
   
   ### Expected behavior
   
   Execute `SELECT * FROM t_merchant WHERE business_code LIKE '%18'` successfully.
   
   ### Actual behavior
   
   ```
   [INFO ] 2022-12-21 09:22:49.583 [Connection-1-ThreadExecutor] ShardingSphere-SQL - Logic SQL: SELECT * FROM t_merchant;
   [INFO ] 2022-12-21 09:22:49.583 [Connection-1-ThreadExecutor] ShardingSphere-SQL - Actual SQL: ds_1 ::: SELECT "t_merchant"."merchant_id", "t_merchant"."country_id", "t_merchant"."merchant_name", "t_merchant"."business_code_cipher" AS "business_code", "t_merchant"."telephone_cipher" AS "telephone", "t_merchant"."creation_date" FROM t_merchant;
   [ERROR] 2022-12-21 09:22:51.940 [Connection-1-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
   java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 24
   	at java.util.Base64$Decoder.decode0(Base64.java:742)
   	at java.util.Base64$Decoder.decode(Base64.java:526)
   	at java.util.Base64$Decoder.decode(Base64.java:549)
   	at org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm.decrypt(AESEncryptAlgorithm.java:77)
   	at org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm.decrypt(AESEncryptAlgorithm.java:41)
   	at org.apache.shardingsphere.encrypt.merge.dql.EncryptMergedResult.getValue(EncryptMergedResult.java:57)
   	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.getRowData(DatabaseCommunicationEngine.java:350)
   	at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.getQueryRowPacket(PostgreSQLComQueryExecutor.java:126)
   	at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.getQueryRowPacket(PostgreSQLComQueryExecutor.java:60)
   	at org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.writeDataPackets(PostgreSQLCommandExecuteEngine.java:113)
   	at org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.processSimpleQuery(PostgreSQLCommandExecuteEngine.java:94)
   	at org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.writeQueryData(PostgreSQLCommandExecuteEngine.java:85)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:116)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:748)
   ```
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   First, config encrypt rule.
   
   ```
   databaseName: encrypt_db
   
   dataSources:
     ds_0:
       url: jdbc:postgresql://127.0.0.1:5432/demo_ds_0
       username: postgres
       password: 123456
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
     ds_1:
       url: jdbc:postgresql://127.0.0.1:5432/demo_ds_1
       username: postgres
       password: 123456
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
   
   rules:
   - !ENCRYPT
     encryptors:
       aes_encryptor:
         type: AES
         props:
           aes-key-value: 123456abc
       like_encryptor:
         type: CHAR_DIGEST_LIKE
         props:
           mask: 4093
     tables:
       t_merchant:
         columns:
           business_code:
             plainColumn: business_code_plain
             cipherColumn: business_code_cipher
             likeQueryColumn: business_code_like
             encryptorName: aes_encryptor
             likeQueryEncryptorName: like_encryptor
           telephone:
             plainColumn: telephone_plain
             cipherColumn: telephone_cipher
             likeQueryColumn: telephone_like
             encryptorName: aes_encryptor
             likeQueryEncryptorName: like_encryptor
   ```
   And then execute init sql.
   
   ```sql
   DROP TABLE t_merchant;
   
   CREATE TABLE t_merchant (merchant_id INT PRIMARY KEY, country_id SMALLINT NOT NULL, merchant_name VARCHAR(50) NOT NULL, business_code VARCHAR(50) NOT NULL, telephone CHAR(50) NOT NULL, creation_date DATE NOT NULL);
   
   
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(1, 86, 'tencent', '86000001', '86100000001', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(2, 86, 'haier', '86000002', '86100000002', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(3, 86, 'huawei', '86000003', '86100000003', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(4, 86, 'alibaba', '86000004', '86100000004', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(5, 86, 'lenovo', '86000005', '86100000005', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(6, 86, 'moutai', '86000006', '86100000006', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(7, 86, 'baidu', '86000007', '86100000007', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(8, 86, 'xiaomi', '86000008', '86100000008', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(9, 86, 'vivo', '86000009', '86100000009', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(10, 86, 'oppo', '86000010', '86100000010', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(11, 1, 'google', '01000011', '01100000011', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(12, 1, 'walmart', '01000012', '01100000012', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(13, 1, 'amazon', '01000013', '01100000013', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(14, 1, 'apple', '01000014', '01100000014', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(15, 1, 'microsoft', '01000015', '01100000015', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(16, 1, 'dell', '01000016', '01100000016', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(17, 1, 'johnson', '01000017', '01100000017', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(18, 1, 'intel', '01000018', '01100000018', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(19, 1, 'hp', '01000019', '01100000019', '2017-08-08');
   INSERT INTO t_merchant(merchant_id, country_id, merchant_name, business_code, telephone, creation_date) values(20, 1, 'tesla', '01000020', '01100000020', '2017-08-08');
   ```
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tristaZero closed issue #23003: ERROR: Input byte array has incorrect ending byte at 24 occurs when I config encrypt rule on PostgreSQL/openGauss char type column

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #23003: ERROR:  Input byte array has incorrect ending byte at 24 occurs when I config encrypt rule on PostgreSQL/openGauss char type column
URL: https://github.com/apache/shardingsphere/issues/23003


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org