云服务器内容精选

  • 升级CodeArts Repo的SSH功能 代码托管服务 SSH功能下线部分不安全的加密算法。 当前KEX (Key Exchange)和MAC(消息验证码)不再支持以下算法。 KEX (Key Exchange)不支持算法如下: diffie-hellman-group18-sha512 diffie-hellman-group-exchange-sha1 diffie-hellman-group-exchange-sha256 MAC(消息验证码)不支持算法如下: hmac-md5 hmac-md5-96 hmac-sha1-etm@openssh.com hmac-sha1-96-etm@openssh.com hmac-md5-etm@openssh.com hmac-md5-96-etm@openssh.com umac-64@openssh.com umac-128@openssh.com 升级您的的代码提交工具至最新版本(如:git bash,eclipse,idea等),新版本默认使用更为安全的算法。 如有疑问请联系技术支持工程师。 父主题: 认证鉴权问题
  • Incorrect IAM authentication information: decrypt token fail { "error_msg": "Incorrect IAM authentication information: decrypt token fail", "error_code": "APIG.0301", "request_id": "******" } 可能原因 用户的API所属IAM认证,TOKEN解析失败。 解决办法 检查获取的token是否为对应IAM账号下的token。 检查获取token的方法,token是否正确。 检查获取token的环境与调用的环境是否一致。
  • Incorrect IAM authentication information: Get secretKey failed { "error_msg": "Incorrect IAM authentication information: Get secretKey failed,ak:******,err:ak not exist", "error_code": "APIG.0301", "request_id": "******" } 可能原因 用户的API所属IAM认证,使用AK/SK签名方式访问,但是AK不存在。 解决方法 检查AK填写是否正确。
  • Incorrect IAM authentication information: verify aksk signature fail { "error_msg": "Incorrect IAM authentication information: verify aksk signature fail, ...... "error_code": "APIG.0301", "request_id": "******" }
  • Incorrect IAM authentication information: AK access failed to reach the limit,forbidden { "error_msg": "Incorrect IAM authentication information: AK access failed to reach the limit,forbidden." ...... "error_code": "APIG.0301", "request_id": "******" }
  • Java中Content-MD5的计算方法示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.security.MessageDigest; import sun.misc.BASE64Encoder; import java.io.UnsupportedEncodingException; import java.security.NoSuchAlgorithmException; public class Md5{ public static void main(String[] args) { try { String exampleString = "blog"; MessageDigest messageDigest = MessageDigest.getInstance("MD5"); BASE64Encoder encoder = new BASE64Encoder(); String contentMd5 = encoder.encode(messageDigest.digest(exampleString.getBytes("utf-8"))); System.out.println("Content-MD5:" + contentMd5); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { e.printStackTrace(); } } }
  • Token认证 Token在计算机系统中代表令牌(临时)的意思,拥有Token就代表拥有某种权限。Token认证就是在调用API的时候将Token加到请求消息头,从而通过身份认证,获得操作API的权限。 Token可通过调用获取用户Token接口获取,调用本服务API需要project级别的Token,即调用获取用户Token接口时,请求body中auth.scope的取值需要选择project,如下所示。 username、domainname 的获取请参考获取账号名和账号ID。password为用户密码。 { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "********", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "xxxxxxxx" } } } } Token的有效期为24小时,需要使用一个Token鉴权时,可以先缓存起来,避免频繁调用。 GES服务必须通过project的方式来获取token,不支持scope为domain的方式。 获取Token 后,再调用其他接口时,您需要在请求消息头中添加“X-Auth-Token”,其值即为Token。例如Token值为“ABCDEFJ....”,则调用接口时将“X-Auth-Token: ABCDEFJ....”加到请求消息头即可,如下所示。 GET https://iam.cn-north-1.myhuaweicloud.com/v3/auth/projects Content-Type: application/json X-Auth-Token: ABCDEFJ.... 您还可以通过这个视频教程了解如何使用Token认证:https://bbs.huaweicloud.com/videos/101333 。
  • 用户签名验证 OBS通过AK/SK对请求进行签名,在向OBS发送请求时,客户端发送的每个消息头需要包含由SK、请求时间、请求类型等信息生成的签名信息。 AK(Access Key ID):访问密钥ID。与私有访问密钥关联的唯一标识符;访问密钥ID和私有访问密钥一起使用,对请求进行加密签名。 SK(Secret Access Key):与访问密钥ID结合使用的密钥,对请求进行加密签名,可标识发送方,并防止请求被修改。 用户可以在IAM服务中获取AK和SK,获取的方法请参见获取访问密钥(AK/SK)。 OBS根据应用场景,提供了Header中携带签名、URL中携带签名和基于浏览器上传的表单中携带签名3种签名计算方式。 OBS提供的SDK已集成了签名计算,建议您使用SDK进行开发。 以Header中携带签名为例,用户签名验证流程如表1所示。Header中携带签名方法的具体参数说明及代码示例,请参见Header中携带签名。 表1 OBS签名计算和验证步骤 步骤 示例 签名计算 1. 构造HTTP消息 PUT /object HTTP/1.1 Host: bucket.obs.cn-north-4.myhuaweicloud.com Date: Tue, 04 Jun 2019 06:54:59 GMT Content-Type: text/plain Content-Length: 5913 2. 按照签名规则计算StringToSign StringToSign = HTTP-Verb + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + Date + "\n" + CanonicalizedHeaders + CanonicalizedResource 3. 准备AK和SK AK: ****** SK: ****** 4. 计算签名Signature Signature = Base64( HMAC-SHA1( SecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ) 5. 添加签名头域发送到OBS服务 PUT /object HTTP/1.1 Host: bucket.obs.cn-north-4.myhuaweicloud.com Date: Tue, 04 Jun 2019 06:54:59 GMT Content-Type: text/plain Content-Length: 5913 Authorization: OBS AccessKeyID:Signature 签名验证 6. 接收HTTP消息 PUT /object HTTP/1.1 Host: bucket.obs.cn-north-4.myhuaweicloud.com Date: Tue, 04 Jun 2019 06:54:59 GMT Content-Type: text/plain Content-Length: 5913 Authorization: OBS AccessKeyID:Signature 7. 根据请求中的AK获取SK 从头域Authorization中取出AK,去IAM取回用户的SK 8. 按照签名规则计算StringToSign StringToSign = HTTP-Verb + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + Date + "\n" + CanonicalizedHeaders + CanonicalizedResource 9. 计算签名Signature Signature = Base64( HMAC-SHA1( SecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) ) 10. 验证签名 验证头域Authorization中的Signature与服务端计算的Signature是否相等 相等:签名验证通过 不相等:签名验证失败 父主题: 认证鉴权