阿里云短信服务在本地发送成功,部署到阿里云服务器报错HMAC-SHA1 not supported.
解释问题1、阿里云的接口是采用hamc-sha1算法进行签名计算,以确保接口调用的安全性。2、java和C#都调整了hamc-sha1算法的实现路径。解决问题java:一般发生在jdk8上,部分jdk7也有第一步,需要核实/jre/lib/ext下是否有sunjce_provider.jar第二步、核对java启动环境是否加载了“sunjce_provider.jar”(直接将sunjce_provider.jar复制到工程jar目录libs亦可实现强行加载)即 cp /soft/jdk1.X.X_XX/jre/lib/ext/sunjce_provider.jar /../api_demo/alicom-dysms-api/libs/附网上帮助Copying sunjce_provider.jar from $JAVA_HOME/jre/lib/ext to the lib directory of the container.Adding the following line to my code:java.security.Security.addProvider(new com.sun.crypto.provider.SunJCE());解决问题C#版: 发生在从net2.0net3.5net4.0 升级到core2.0时候。1、命名空间都发生了变化,不能使用参数实例化对象。即将Aliyun.Acs.Core.Auth.ShaHmac1的46行 KeyedHashAlgorithm.Create('HMACSHA1')改为 new HMACSHA1()。https://github.com/aliyun/aliyun-openapi-net-sdk/blob/master/aliyun-net-sdk-core/Auth/ShaHmac1.cs using (var algorithm = new HMACSHA1())// KeyedHashAlgorithm.Create('HMACSHA1'))
赞0
踩0