Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SM2相关example例程运行报错 #8

Open
zhangyongann opened this issue Oct 20, 2023 · 11 comments
Open

SM2相关example例程运行报错 #8

zhangyongann opened this issue Oct 20, 2023 · 11 comments

Comments

@zhangyongann
Copy link

开发者您好,我电脑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
Copy link
Author

补充更详细的系统信息:

系统类型: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

@Hyperia-CN
Copy link

开发者您好,我的电脑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

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

解决了吗?

@Beitadoge
Copy link

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

@r1is
Copy link

r1is commented Nov 17, 2023

开发者您好,我电脑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
Copy link

Jinkeee commented Nov 22, 2023

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

开发者您好,我电脑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

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

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

@sqs404
Copy link

sqs404 commented Dec 31, 2023

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

@KKKGod
Copy link

KKKGod commented Jan 10, 2024

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

@j-z10
Copy link

j-z10 commented Mar 28, 2024

降低GmSSL版本到 v3.1.1

@yujingyue9166
Copy link

降低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

@Zhanghanhan1
Copy link

降低GmSSL版本到 v3.1.1

可是装的就是3.1.1

@j-z10
Copy link

j-z10 commented Mar 30, 2024

降低GmSSL版本到 v3.1.1

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants