Standard.Licensing icon indicating copy to clipboard operation
Standard.Licensing copied to clipboard

Without ExpireAt?

Open SonaBIMDev opened this issue 3 years ago • 2 comments
trafficstars

Hi, is it possible to generate a Licence without an ExpiresAt condition? Thx

SonaBIMDev avatar Oct 21 '22 08:10 SonaBIMDev

Yes I think you can. I used the example provided in the README and commented out the ExpiresAt, which still produces a XML string.

var passPhrase = "TestPassphrase";

var keyGenerator = Standard.Licensing.Security.Cryptography.KeyGenerator.Create(); 
var keyPair = keyGenerator.GenerateKeyPair();
var privateKey = keyPair.ToEncryptedPrivateKeyString(passPhrase);  
var publicKey = keyPair.ToPublicKeyString();

var license = License.New()  
    .WithUniqueIdentifier(Guid.NewGuid())  
    .As(LicenseType.Trial)  
    //.ExpiresAt(DateTime.Now.AddDays(30))  
    .WithMaximumUtilization(5)  
    .WithProductFeatures(new Dictionary<string, string>  
    {  
        {"Sales Module", "yes"},  
        {"Purchase Module", "yes"},  
        {"Maximum Transactions", "10000"}  
    })  
    .LicensedTo("John Doe", "[email protected]")  
    .CreateAndSignWithPrivateKey(privateKey, passPhrase);
    
Console.WriteLine(license.ToString());

AntiGuideAkquinet avatar Feb 24 '23 06:02 AntiGuideAkquinet

Hi @AntiGuideAkquinet Wow! I didn't believe in it anymore! Thx for sharing!

SonaBIMDev avatar Feb 24 '23 07:02 SonaBIMDev