Skip to content

Commit 157e148

Browse files
committed
Merge pull request #15 from AzCiS/parvezah
Fixing the Error Messages shown when decrytion fails with the given regi...
2 parents 443b2b3 + 4ba3bdb commit 157e148

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Encryption/EncryptionCmdLetHelper.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.Security.Cryptography;
1617
using Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets.Library;
1718
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
1819

@@ -89,7 +90,19 @@ public static void ValidatePersistedCIK(StorSimpleCmdletBase cmdlet, string reso
8990
string cik = RetrieveCIK(cmdlet, resourceId);
9091

9192
StorSimpleCryptoManager cryptMgr = new StorSimpleCryptoManager(cmdlet.StorSimpleClient);
92-
string rakPub = cryptMgr.GetPlainTextRAKPub(cik);
93+
94+
string rakPub = null;
95+
96+
try
97+
{
98+
rakPub = cryptMgr.GetPlainTextRAKPub(cik);
99+
}
100+
catch (CryptographicException exception)
101+
{
102+
// This case is to handle the failures during decrypting the Rak Pub
103+
cmdlet.WriteVerbose(string.Format(Resources.CIKInvalidWithException, exception.Message));
104+
throw new Exception(Resources.CIKInvalidWhileDecrypting);
105+
}
93106

94107
if (string.IsNullOrEmpty(rakPub))
95108
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,4 +507,10 @@
507507
<data name="JobNotRunningOrCancellable" xml:space="preserve">
508508
<value>Cannot stop job with id {0}. It is not a running cancellable job.</value>
509509
</data>
510+
<data name="CIKInvalidWhileDecrypting" xml:space="preserve">
511+
<value>Invalid Registration Key, Please enter the valid registration key copied from the Portal.</value>
512+
</data>
513+
<data name="CIKInvalidWithException" xml:space="preserve">
514+
<value>Invalid value for Registration Key. CIK provided couldnt be used to decrypt the secrets! The exact exception while decrypting is "{0}"!</value>
515+
</data>
510516
</root>

0 commit comments

Comments
 (0)