How to login to an Azure Blob Storage Sftp from Java?

127 Views Asked by At

Currently I'm trying to access to an Azure Blob Storage through Sftp defined with Private key authentication, but due to client restrictions I'm not able to have the Private key file directly, I've tried to get the Private Key from an Azure Key vault Key using the following code:

   KeyClient keyClient = new KeyClientBuilder()
            .vaultUrl(keyVaultUrl)
            .credential(new ClientSecretCredentialBuilder()
                    .clientId(clientId)
                    .clientSecret(clientSecret)
                    .tenantId(tenantId)
                    .build())
            .buildClient();

    KeyVaultKey rsaKey = keyClient.getKey("<azure-keyvault-key>");
    JsonWebKey jsonWebKey = rsaKey.getKey();
    PrivateKey privateKey = jsonWebKey.toRsa(true).getPrivate();

But the Keyvault response only has the Public key, is there a way to access with other method?

Azure Blob Storage Sftp: https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support

I've tried to get the private key from the Azure key vault key, but it only gets the Public part.

I made a try using passing to an Apache Camel Sftp route the KeyPair given by the Keyvault key but it still needs the Private part.

0

There are 0 best solutions below