简体   繁体   中英

Enforce TLS 1.2 when uploading files in azure blob storage using Java sdk

Java SDK for Azure Blob Storage uses NFS but we want to use TLS 1.2 when uploading files using blobclient. Though the minimum setting in account is set as TLS 1.2 but how can client upload files from their application using 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));

After research, found below code which enforces TLS 1.2. Writing it down in case it helps others.

System.setProperty("jdk.tls.client.protocols", "TLSv1.2");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM