Prepare Pro 1.0.1 imports and license tooling
This commit is contained in:
1 parent
62f28c5621
commit
0b5017739c
13 files changed
+437
-48
No files matched your search
@@ -240,14 +240,25 @@ internal sealed class LicenseRepository
|
||||
{
|
||||
if (File.Exists(PrivateKeyPath))
|
||||
{
|
||||
using var existing = LoadPrivateKey();
|
||||
if (!_allowKeyGeneration && !IsExpectedSigningKey(existing))
|
||||
try
|
||||
{
|
||||
throw new CryptographicException("La chiave locale non corrisponde alla chiave pubblica incorporata in LME Pro.");
|
||||
}
|
||||
using var existing = LoadPrivateKey();
|
||||
if (!_allowKeyGeneration && !IsExpectedSigningKey(existing))
|
||||
{
|
||||
PreserveIncompatiblePrivateKey();
|
||||
File.WriteAllText(PublicKeyPath, ExpectedPublicKeyPem, Encoding.ASCII);
|
||||
return;
|
||||
}
|
||||
|
||||
File.WriteAllText(PublicKeyPath, existing.ExportSubjectPublicKeyInfoPem(), Encoding.ASCII);
|
||||
return;
|
||||
File.WriteAllText(PublicKeyPath, existing.ExportSubjectPublicKeyInfoPem(), Encoding.ASCII);
|
||||
return;
|
||||
}
|
||||
catch (CryptographicException) when (!_allowKeyGeneration)
|
||||
{
|
||||
PreserveIncompatiblePrivateKey();
|
||||
File.WriteAllText(PublicKeyPath, ExpectedPublicKeyPem, Encoding.ASCII);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_allowKeyGeneration)
|
||||
@@ -265,6 +276,15 @@ internal sealed class LicenseRepository
|
||||
File.SetAttributes(PrivateKeyPath, FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
private void PreserveIncompatiblePrivateKey()
|
||||
{
|
||||
File.SetAttributes(PrivateKeyPath, FileAttributes.Normal);
|
||||
var preservedPath = Path.Combine(
|
||||
_directory,
|
||||
$"manual-license-private-incompatible-{DateTime.UtcNow:yyyyMMddHHmmss}.dpapi");
|
||||
File.Move(PrivateKeyPath, preservedPath);
|
||||
}
|
||||
|
||||
private static bool IsExpectedSigningKey(RSA rsa)
|
||||
{
|
||||
using var expected = RSA.Create();
|
||||
|
||||
Reference in new issue
Block a user