Skip to content

Commit 9c9430d

Browse files
committed
由温仰发起的CORE-V3 SDK自动发布, BUILD_ID=114, 版本号:2.5.4
发布日志: 1, disable [publicKeyId] auth type in Windows because 'pycrypto' is not supported
1 parent 4190268 commit 9c9430d

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

aliyun-python-sdk-core-v3/ChangeLog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2017-12-14 Version: 2.5.4
2+
1, disable [publicKeyId] auth type in Windows because 'pycrypto' is not supported
3+
14
2017-12-12 Version: 2.5.3
25
1, remove bad smell codes
36
2, bugfix: the invoke-type metric will lost while send rpc request with common api
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.5.3"
1+
__version__ = "2.5.4"

aliyun-python-sdk-core-v3/aliyunsdkcore/acs_exception/error_code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
SDK_INVALID_CREDENTIAL = 'SDK.InvalidCredential'
3636
SDK_INVALID_SESSION_EXPIRATION = 'SDK.InvalidSessionExpiration'
3737
SDK_GET_SESSION_CREDENTIAL_FAILED = 'SDK.GetSessionCredentialFailed'
38-
SDK_INVALID_PARAMS = 'SDK.InvalidParams'
38+
SDK_INVALID_PARAMS = 'SDK.InvalidParams'
39+
SDK_NOT_SUPPORT = 'SDK.NotSupport'

aliyun-python-sdk-core-v3/aliyunsdkcore/auth/algorithm/sha_hmac256.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,33 @@
1818
# coding=utf-8
1919

2020
import base64
21-
from Crypto.Signature import PKCS1_v1_5
22-
from Crypto.Hash import SHA256
23-
from Crypto.PublicKey import RSA
21+
import platform
22+
from aliyunsdkcore.acs_exception import exceptions
23+
from aliyunsdkcore.acs_exception import error_code
24+
2425

2526

2627
def get_sign_string(source, access_secret):
27-
if isinstance(access_secret, str):
28-
access_secret = bytearray(access_secret, "utf-8")
29-
secret = base64.decodebytes(access_secret)
30-
key = RSA.importKey(secret)
31-
if isinstance(source, str):
32-
source = bytearray(source, "utf-8")
33-
h = SHA256.new(source)
34-
signer = PKCS1_v1_5.new(key)
35-
signed_bytes = signer.sign(h)
36-
signed_base64 = base64.encodebytes(signed_bytes)
37-
signature = str(signed_base64, "utf-8").replace('\n', '')
38-
return signature
28+
if platform.system() != "Windows":
29+
from Crypto.Signature import PKCS1_v1_5
30+
from Crypto.Hash import SHA256
31+
from Crypto.PublicKey import RSA
32+
if isinstance(access_secret, str):
33+
access_secret = bytearray(access_secret, "utf-8")
34+
secret = base64.decodebytes(access_secret)
35+
key = RSA.importKey(secret)
36+
if isinstance(source, str):
37+
source = bytearray(source, "utf-8")
38+
h = SHA256.new(source)
39+
signer = PKCS1_v1_5.new(key)
40+
signed_bytes = signer.sign(h)
41+
signed_base64 = base64.encodebytes(signed_bytes)
42+
signature = str(signed_base64, "utf-8").replace('\n', '')
43+
return signature
44+
else:
45+
message = "uth type [publicKeyId] is disabled in Windows because 'pycrypto' is not supported," \
46+
" we will resolve this soon"
47+
raise exceptions.ClientException(error_code.SDK_NOT_SUPPORT, message)
3948

4049

4150
def get_signer_name():

aliyun-python-sdk-core-v3/setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
from setuptools import setup, find_packages
2222
import os
23+
import platform
24+
import logging
2325

2426
"""
2527
setup module for core.
@@ -44,6 +46,14 @@
4446
finally:
4547
desc_file.close()
4648

49+
requires = []
50+
if platform.system() != "Windows":
51+
requires.append("pycrypto>=2.6.1")
52+
else:
53+
logging.warning(
54+
"auth type [publicKeyId] is disabled because 'pycrypto' not support windows, we will resolve this soon")
55+
56+
4757
setup(
4858
name=NAME,
4959
version=VERSION,

0 commit comments

Comments
 (0)