2017-01-25 7 views
2

다음과 같은 방법으로 테이블을 암호화하고 있습니다. 검색하는 동안Azure 테이블 저장소에서 엔티티를 검색하는 동안 "OAEP 패딩을 디코딩하는 동안 오류가 발생했습니다"라는 오류 메시지가 나타납니다.

public TableRequestOptions EncryptTableStorage() 
    { 
     // Create the IKey used for encryption. 
     var key = new RsaKey("mykey"); 

     var policy = new TableEncryptionPolicy(key, null); 

     TableRequestOptions options = new TableRequestOptions() 
     { 
      EncryptionPolicy = policy 
     }; 


     return options; 

    } 

내 암호화 된 개체

[EncryptProperty] 
public string ConsumerId { get; set; } 

, 다음 코드

var query = new TableQuery<CloudModelDetail>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, cloudModelDetail.PartitionKey)); 
foreach (var entity in azureStorageAccount.VerifyCloudTable.ExecuteQuery(query, azureStorageAccount.EncryptTableStorage())) 
{ 
    Console.WriteLine("{0}, {1}\t{2}\t{3}", entity.PartitionKey, entity.RowKey, 
        entity.ConsumerId, entity.ScoreVariables); 
} 

내가 암호 해독 오류가 없다는 오류를 얻고을 사용하고 있습니다. 내부 예외는 "OAEP 패딩을 디코딩하는 동안 오류가 발생했습니다."라고 말합니다.

답변

0

코드 및 공식 document 코드를 사용해 보았습니다. 쿼리 결과에서 하나의 엔티티 만 테이블에 쿼리하면 해독 된 정보를 올바르게 가져올 수 있습니다. 둘 이상의 엔티티가 있으면 "OAEP 패딩을 디코딩하는 동안 오류가 발생했습니다."라는 동일한 오류가 발생합니다. 네가 말했듯이. 그것은 현재 한 번에 더 많은 엔티티를 쿼리하는 것을 지원하지 않는 SDK 인 것 같습니다. 우리는 요구 사항을 Azure storage SDK 프로젝트에보고하거나 feedback Azure 팀에게 알릴 수 있습니다.

업데이트 :

데모 코드 :

static void Main(string[] args) 
    { 
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
     "Your storage connection string"); 

     RsaKey key = new RsaKey("mykey" /* key identifier */); 

     // Create the encryption policy to be used for upload and download. 
     TableEncryptionPolicy policy = new TableEncryptionPolicy(key, null); 

     TableRequestOptions options = new TableRequestOptions 
     { 
      EncryptionPolicy = policy 
     }; 


     CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); 

     // Create the CloudTable object that represents the "tomtest" table. 
     CloudTable table = tableClient.GetTableReference("tomtest"); 

     table.CreateIfNotExists(); 

     var insertList = new List<CloudModelDetail>(); 

     var cloudModelDetailEntity = new CloudModelDetail { ConsumerId = "0001-"+Guid.NewGuid() }; 

     table.Execute(TableOperation.Insert(cloudModelDetailEntity), options); 

     TableRequestOptions retrieveoptions = new TableRequestOptions 
     { 
      EncryptionPolicy = policy 
     }; 

     var query = 
      new TableQuery<CloudModelDetail>().Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, cloudModelDetailEntity.RowKey)); 

     var list = table.ExecuteQuery(query, retrieveoptions); 
     foreach (CloudModelDetail entity in list) 
     { 
      Console.WriteLine($"PartionKey:{entity.PartitionKey},RowKey:{entity.RowKey},ConsumerId: {entity.ConsumerId}"); 
     } 

     Console.ReadKey(); 
    } 



    public class CloudModelDetail : TableEntity 
    { 
     [EncryptProperty] 
     public string ConsumerId { get; set; } 
     public CloudModelDetail() 
     { 
      PartitionKey = "Name"; 
      RowKey = Guid.NewGuid().ToString(); 

     } 
    } 
+1

불행하게도, 내 코드는 같은 오류를주고있다. 뭔가 제안 할 수 있니? 엔티티의 메타 데이터를 우연히 업데이트합니까? – Sameer

+0

제 코드를 사용해보세요. 답변을 업데이트했습니다. –

+0

업데이트 된 코드에서 동일한 예외가 발생하고 TableOperation.Retrieve를 사용할 때. –

0

업데이트 : 그것은 밖으로 문제가 해결되지 않았다집니다; 나는 암호화를 무력화시킨 무언가를 우연히 바 꾸었습니다.

Execute 및 ExecuteQuerySegmented와 함께 예외가 발생했습니다. 나에게 솔루션은 키의 활성화 날짜를 설정하는 것으로 판명되었습니다 (이전에는 설정되지 않았기 때문에 확인란이 선택되지 않았습니다). 단일 엔티티를 해독하면서

Key Version Configuration