0

用于 Azure Blob 存储的 Java SDK 使用 NFS,但我们希望在使用 blobclient 上传文件时使用 TLS 1.2。虽然帐户中的最低设置设置为 TLS 1.2,但客户端如何使用 TLS 1.2 从其应用程序上传文件?

BlobServiceClient blobSvcClient = new BlobServiceClientBuilder()
           .endpoint(storageActUrl) // https://myaccount.blob.core.windows.net/testcontainer/blob.txt
           .sasToken(sasToken)
           .buildClient(); 
BlobClient blobClient = blobSvcClient.getBlobContainerClient(containerName).getBlobClient(blobName);
BlobHttpHeaders blobHeaders = new BlobHttpHeaders().setContentLanguage("en-US").setContentType("binary");
blobClient.uploadFromFile(filePath, null, headers, null, AccessTier.HOT, new BlobRequestConditions(), Duration.ofMinutes(30));

4

1 回答 1

0

经过研究,发现下面的代码强制执行 TLS 1.2。把它写下来以防它帮助别人。

System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
于 2022-02-25T06:40:10.587 回答