릴리스 노트
제품 공지
java.security.InvalidKeyException: Illegal key size or default parameters와 같은 이상 경고가 뜹니다. 이 경우 정책적 제한이 없는 Oracle의 JCE 권한 파일을 JRE 환경에 배포해야 합니다. 현재 사용 중인 JDK 버전에 따라 해당하는 파일을 각각 다운로드하여 압축을 해제한 후 JAVA_HOME의 jre/lib/security 디렉터리에 저장하십시오.// 사용자의 개인 정보(secretId, secretKey) 초기화// SECRETID와 SECRETKEY는 CAM 콘솔에 로그인하여 조회 및 관리String secretId = "SECRETID";String secretKey = "SECRETKEY";COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);// 버킷 리전 설정, COS 리전의 약칭은 https://www..com/document/product/436/6224 참고ClientConfig clientConfig = new ClientConfig(new Region("COS_REGION"));// 요청 헤더가 조작되어 데이터를 암호화하지 못하는 문제를 방지하기 위해, 요청 시 https 프로토콜만 사용할 것을 권장clientConfig.setHttpProtocol(HttpProtocol.https);// KMS 서비스의 마스터 키String cmk = "XXXXXXX";//// KMS 서비스 리전과 COS 버킷 리전이 동일하지 않은 경우 단독 설정 필요//String kmsRegion = "XXXXX";// KMS 암호화 자료 초기화KMSEncryptionMaterials encryptionMaterials = new KMSEncryptionMaterials(cmk);// AES/GCM 모드를 사용하여 암호화 정보를 파일 메타 정보에 저장CryptoConfiguration cryptoConf = new CryptoConfiguration(CryptoMode.AuthenticatedEncryption).withStorageMode(CryptoStorageMode.ObjectMetadata);//// KMS 서비스 리전과 COS 리전이 동일하지 않은 경우 암호화 설정에서 KMS 서비스 리전 지정//cryptoConf.setKmsRegion(kmsRegion);//// 필요한 경우 KMS 서비스의 cmk에 해당 설명 정보 설정 가능// encryptionMaterials.addDescription("yourDescKey", "yourDescValue");// 암호화된 클라이언트 EncryptionClient를 생성합니다. COSEncryptionClient는 COSClient의 서브 유형으로, COSClient가 지원하는 모든 인터페이스를 지원합니다.// EncryptionClient는 COSClient의 업로드/다운로드 로직을 덮어쓰기 하며 내부적으로 암호화 작업을 실행합니다. 다른 작업 실행 로직은 COSClient와 동일합니다.COSEncryptionClient cosEncryptionClient =new COSEncryptionClient(new COSStaticCredentialsProvider(cred),new KMSEncryptionMaterialsProvider(encryptionMaterials), clientConfig,cryptoConf);// 파일 업로드// putObject의 예시, 고급 API 업로드는 TransferManager 생성 시 COSEncryptionClient 객체를 전송할 때만 사용String bucketName = "examplebucket-1250000000";String key = "exampleobject";File localFile = new File("localFilePath");PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, localFile);cosEncryptionClient.putObject(putObjectRequest);cosEncryptionClient.shutdown();
// 사용자의 개인 정보(secretId, secretKey) 초기화// SECRETID와 SECRETKEY는 CAM 콘솔에 로그인하여 조회 및 관리String secretId = "SECRETID";String secretKey = "SECRETKEY";COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);// 버킷 리전 설정, COS 리전의 약칭은 https://www..com/document/product/436/6224 참고ClientConfig clientConfig = new ClientConfig(new Region("COS_REGION"));// 대칭 키 생성, 생성된 대칭 키는 파일에 저장 가능KeyGenerator symKeyGenerator = KeyGenerator.getInstance("AES");symKeyGenerator.init(256);SecretKey symKey = symKeyGenerator.generateKey();EncryptionMaterials encryptionMaterials = new EncryptionMaterials(symKey);// AES/GCM 모드를 사용하여 암호화 정보를 파일 메타데이터에 저장CryptoConfiguration cryptoConf = new CryptoConfiguration(CryptoMode.AuthenticatedEncryption).withStorageMode(CryptoStorageMode.ObjectMetadata);// 암호화된 클라이언트 EncryptionClient를 생성합니다. COSEncryptionClient는 COSClient의 서브 유형으로, COSClient가 지원하는 모든 인터페이스를 지원합니다.// EncryptionClient는 COSClient의 업로드/다운로드 로직을 덮어쓰기 하며 내부적으로 암호화 작업을 실행합니다. 다른 작업 실행 로직은 COSClient와 동일합니다.COSEncryptionClient cosEncryptionClient =new COSEncryptionClient(new COSStaticCredentialsProvider(cred),new StaticEncryptionMaterialsProvider(encryptionMaterials), clientConfig,cryptoConf);// 파일 업로드// putObject의 예시, 고급 API 업로드는 TransferManager 생성 시 COSEncryptionClient 객체를 전송할 때만 사용String bucketName = "examplebucket-1250000000";String key = "exampleobject";File localFile = new File(localFilePath);PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, localFile);cosEncryptionClient.putObject(putObjectRequest);cosEncryptionClient.shutdown();
// 사용자의 개인 정보(secretId, secretKey) 초기화// SECRETID와 SECRETKEY는 CAM 콘솔에 로그인하여 조회 및 관리String secretId = "SECRETID";String secretKey = "SECRETKEY";COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);// 버킷 리전 설정, COS 리전의 약칭은 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1 참고ClientConfig clientConfig = new ClientConfig(new Region("COS_REGION"));// 비대칭 키 생성KeyPairGenerator keyGenerator = KeyPairGenerator.getInstance("RSA");SecureRandom srand = new SecureRandom();keyGenerator.initialize(1024, srand);KeyPair asymKeyPair = keyGenerator.generateKeyPair();EncryptionMaterials encryptionMaterials = new EncryptionMaterials(asymKeyPair);// AES/GCM 모드를 사용하여 암호화 정보를 파일 메타데이터에 저장CryptoConfiguration cryptoConf = new CryptoConfiguration(CryptoMode.AuthenticatedEncryption).withStorageMode(CryptoStorageMode.ObjectMetadata);// 암호화된 클라이언트 EncryptionClient를 생성합니다. COSEncryptionClient는 COSClient의 서브 유형으로, COSClient가 지원하는 모든 인터페이스를 지원합니다.// EncryptionClient는 COSClient의 업로드/다운로드 로직을 덮어쓰기 하며 내부적으로 암호화 작업을 실행합니다. 다른 작업 실행 로직은 COSClient와 동일합니다.COSEncryptionClient cosEncryptionClient =new COSEncryptionClient(new COSStaticCredentialsProvider(cred),new StaticEncryptionMaterialsProvider(encryptionMaterials), clientConfig,cryptoConf);// 파일 업로드// putObject의 예시, 고급 API 업로드는 TransferManager 생성 시 COSEncryptionClient 객체를 전송할 때만 사용String bucketName = "examplebucket-1250000000";String key = "exampleobject";File localFile = new File(localFilePath);PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, localFile);cosEncryptionClient.putObject(putObjectRequest);cosEncryptionClient.shutdown();
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback