GmSSL-Python icon indicating copy to clipboard operation
GmSSL-Python copied to clipboard

SM2相关example例程运行报错

Open zhangyongann opened this issue 1 year ago • 11 comments

开发者您好,我电脑win11 64位系统,python版本是3.12.0 已经正确安装gmssl和gmssl-python如下:

>>> import gmssl
>>> gmssl.GMSSL_PYTHON_VERSION
'2.2.2'
>>> gmssl.GMSSL_LIBRARY_VERSION
'GmSSL 3.1.1 Dev'

我在测试example文件夹下的例程时,sm3.py和sm4.py运行正常,sm2_key.py运行时报错如下:

File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\gmssl.py", line 436, in export_encrypted_private_key_info_pem
    if gmssl.sm2_private_key_info_encrypt_to_pem(byref(self), c_char_p(passwd), c_void_p(fp)) != 1:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000024

在网上搜索该错误一直没找到解决办法,特在此提问,烦请进行解答,感谢

zhangyongann avatar Oct 20 '23 00:10 zhangyongann

补充更详细的系统信息:

系统类型:64 位操作系统, 基于 x64 的处理器 版本:Windows 11 专业版 22H2

python版本信息:

PS C:\Users\admin> python
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32

zhangyongann avatar Oct 20 '23 01:10 zhangyongann

开发者您好,我的电脑win11 64位系统,python版本是3.12.0 已经正确安装gmssl和gmssl-python如下:

>>> import gmssl
>>> gmssl.GMSSL_PYTHON_VERSION
'2.2.2'
>>> gmssl.GMSSL_LIBRARY_VERSION
'GmSSL 3.1.1 Dev'

我在测试example文件夹下的示例程序时,sm3.py和sm4.py运行正常,sm2_key.py运行错误时报如下:

File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\gmssl.py", line 436, in export_encrypted_private_key_info_pem
    if gmssl.sm2_private_key_info_encrypt_to_pem(byref(self), c_char_p(passwd), c_void_p(fp)) != 1:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000024

在网上搜索该错误一直没有找到解决办法,特此提问,烦请进行解答,谢谢

解决了吗?

Hyperia-CN avatar Oct 25 '23 16:10 Hyperia-CN

同样的版本,我也遇到了这个问题,请问解决了吗?

Beitadoge avatar Nov 16 '23 09:11 Beitadoge

开发者您好,我电脑win11 64位系统,python版本是3.12.0 已经正确安装gmssl和gmssl-python如下:

>>> import gmssl
>>> gmssl.GMSSL_PYTHON_VERSION
'2.2.2'
>>> gmssl.GMSSL_LIBRARY_VERSION
'GmSSL 3.1.1 Dev'

我在测试example文件夹下的例程时,sm3.py和sm4.py运行正常,sm2_key.py运行时报错如下:

File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\gmssl.py", line 436, in export_encrypted_private_key_info_pem
    if gmssl.sm2_private_key_info_encrypt_to_pem(byref(self), c_char_p(passwd), c_void_p(fp)) != 1:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000024

在网上搜索该错误一直没找到解决办法,特在此提问,烦请进行解答,感谢

我也遇到了这个问题,请问解决了吗

r1is avatar Nov 17 '23 03:11 r1is

遇到相同的问题了。请问解决了吗?

开发者您好,我电脑win11 64位系统,python版本是3.12.0 已经正确安装gmssl和gmssl-python如下:

>>> import gmssl
>>> gmssl.GMSSL_PYTHON_VERSION
'2.2.2'
>>> gmssl.GMSSL_LIBRARY_VERSION
'GmSSL 3.1.1 Dev'

我在测试example文件夹下的例程时,sm3.py和sm4.py运行正常,sm2_key.py运行时报错如下:

File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\gmssl.py", line 436, in export_encrypted_private_key_info_pem
    if gmssl.sm2_private_key_info_encrypt_to_pem(byref(self), c_char_p(passwd), c_void_p(fp)) != 1:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation writing 0x0000000000000024

在网上搜索该错误一直没找到解决办法,特在此提问,烦请进行解答,感谢

我也遇到了这个问题,请问解决了吗

Jinkeee avatar Nov 22 '23 07:11 Jinkeee

sm2和sm9的examples都用不了,我也是这个问题

sqs404 avatar Dec 31 '23 10:12 sqs404

使用ctype和python指针交互出问题了 等开发者处理吧

KKKGod avatar Jan 10 '24 08:01 KKKGod

降低GmSSL版本到 v3.1.1

j-z10 avatar Mar 28 '24 03:03 j-z10

降低GmSSL版本到 v3.1.1

GmSSL 是3.1.1 依然是同样的问题

import gmssl gmssl.GMSSL_LIBRARY_VERSION 'GmSSL 3.1.1' gmssl.GMSSL_PYTHON_VERSION '2.2.2'

Traceback (most recent call last): File "sm2_key.py", line 13, in sm2.export_encrypted_private_key_info_pem('sm2.pem', 'password') File "D:\anaconda3\lib\site-packages\gmssl.py", line 432, in export_encrypted_private_key_info_pem if gmssl.sm2_private_key_info_encrypt_to_pem(byref(self), c_char_p(passwd), c_void_p(fp)) != 1: OSError: exception: access violation writing 0x0000000000000024

yujingyue9166 avatar Mar 29 '24 06:03 yujingyue9166

降低GmSSL版本到 v3.1.1

可是装的就是3.1.1

Zhanghanhan1 avatar Mar 29 '24 11:03 Zhanghanhan1

~降低GmSSL版本到 v3.1.1~

看起来是windows下 pem_write 和 pem_read 导致的问题,我这个PR针对windows做了临时处理,把这一步放在python里面执行 你们可以参考一下 https://github.com/j-z10/pygmssl/pull/9

j-z10 avatar Mar 30 '24 07:03 j-z10