gpt4 book ai didi

java - 使用 UploadObjectSingleOperation 示例将文件上传到 aws s3 时出现 SecurityException

转载 作者:太空宇宙 更新时间:2023-11-04 06:24:12 24 4
gpt4 key购买 nike

我在尝试从这里运行示例时捕获了此异常: http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpJava.html有人可以帮忙吗?

Exception in thread "main" java.lang.ExceptionInInitializerError
at javax.crypto.Mac.getInstance(Mac.java:171)
at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:87)
at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:69)
at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:58)
at com.amazonaws.services.s3.internal.S3Signer.sign(S3Signer.java:127)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:652)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:460)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:295)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3697)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1434)
at com.bartoff.s3Utils.UploadObject.main(UploadObject.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:86)
... 16 more
Caused by: java.lang.SecurityException: The jurisdiction policy files are not signed by a trusted signer!
at javax.crypto.JarVerifier.verifyPolicySigned(JarVerifier.java:289)
at javax.crypto.JceSecurity.loadPolicies(JceSecurity.java:316)
at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:265)
at javax.crypto.JceSecurity.access$000(JceSecurity.java:48)
at javax.crypto.JceSecurity$1.run(JceSecurity.java:78)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:76)
... 16 more

最佳答案

这是由于 Java 的安全问题造成的。

解决它。

  • 从 oracle 站点下载 JCE 文件 here
  • 将文件解压到 {YOUR_JDK_PATH}/jdk1.7.0_51/jre/lib/security

关于java - 使用 UploadObjectSingleOperation 示例将文件上传到 aws s3 时出现 SecurityException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27018331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com