2 |
3 | @Title
4 |
5 |
6 | Please take our
7 |
8 | brief survey
9 |
10 |
11 | and tell us what you think.
12 |
13 |
14 | @functions {
15 | [Parameter]
16 | string Title { get; set; } // Demonstrates how a parent component can supply parameters
17 | }
18 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/linker.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Resources/RevokeReason.cs:
--------------------------------------------------------------------------------
1 | namespace ACMESharp.Protocol.Resources
2 | {
3 | ///
4 | /// Reasons for revocation
5 | /// https://tools.ietf.org/html/rfc5280#section-5.3.1
6 | ///
7 | public enum RevokeReason
8 | {
9 | Unspecified = 0,
10 | KeyCompromise = 1,
11 | CaCompromise = 2,
12 | AffiliationChanged = 3,
13 | Superseded = 4,
14 | CessationOfOperation = 5,
15 | CertificateHold = 6,
16 | /*Value 7 is not used*/
17 | RemoveFromCrl = 8,
18 | PrivilegeWithdrawn = 9,
19 | AaCompromise = 10
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Messages/KeyChangeRequest.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using Newtonsoft.Json;
3 |
4 | namespace ACMESharp.Protocol.Messages
5 | {
6 | ///
7 | /// Based on:
8 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-18#section-7.3.5
9 | ///
10 | public class KeyChangeRequest
11 | {
12 | [JsonProperty("account", Required = Required.Always)]
13 | [Required]
14 | public string Account { get; set; }
15 |
16 | [JsonProperty("oldKey", Required = Required.Always)]
17 | [Required]
18 | public object OldKey { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/ACMESharp.MockServer/ACMESharp.MockServer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/ACMESharp/Authorizations/TlsAlpn01ChallengeValidationDetails.cs:
--------------------------------------------------------------------------------
1 | namespace ACMESharp.Authorizations
2 | {
3 | ///
4 | /// https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-05
5 | ///
6 | public class TlsAlpn01ChallengeValidationDetails : IChallengeValidationDetails
7 | {
8 | public const string TlsAlpn01ChallengeType = "tls-alpn-01";
9 | public const string AlpnExtensionName = "acme-tls/1";
10 | public const string AcmeIdentifierExtension = "acmeIdentifier";
11 |
12 | public string ChallengeType => TlsAlpn01ChallengeType;
13 |
14 | public string TokenValue { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/test/ACMESharp.IntegrationTests/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace ACMESharp.IntegrationTests
2 | {
3 | public class Constants
4 | {
5 | /// https://letsencrypt.org/docs/staging-environment/
6 | /// https://letsencrypt.status.io/
7 |
8 | public const string LetsEncryptStagingEndpoint = "https://acme-staging.api.letsencrypt.org/";
9 | public const string LetsEncryptV2StagingEndpoint = "https://acme-staging-v02.api.letsencrypt.org/";
10 | public const string LetsEncryptEndpoint = "https://acme-v01.api.letsencrypt.org/";
11 | public const string LetsEncryptV2Endpoint = "https://acme-v02.api.letsencrypt.org/";
12 | }
13 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Messages/RevokeCertificateRequest.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using Newtonsoft.Json;
3 | using ACMESharp.Protocol.Resources;
4 |
5 | namespace ACMESharp.Protocol.Messages
6 | {
7 | ///
8 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-18#section-7.6
9 | ///
10 | public class RevokeCertificateRequest
11 | {
12 | [JsonProperty("certificate", Required = Required.Always)]
13 | [Required]
14 | public string Certificate { get; set; }
15 |
16 | [JsonProperty("reason")]
17 | public RevokeReason Reason { get; set; } = RevokeReason.Unspecified;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/OrderDetails.cs:
--------------------------------------------------------------------------------
1 | using ACMESharp.Protocol.Resources;
2 |
3 | namespace ACMESharp.Protocol
4 | {
5 | ///
6 | /// An aggregation of Order details including resource payload and ancillary,
7 | /// associated data.
8 | ///
9 | ///
10 | /// This represents a superset of details that are included in responses
11 | /// to several ACME operations regarding an ACME Order, such as
12 | /// Order creation and finalization.
13 | ///
14 | public class OrderDetails
15 | {
16 | public Order Payload { get; set; }
17 |
18 | public string OrderUrl { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/test/PKISharp.SimplePKI.UnitTests/OpenSsl.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.IO;
3 |
4 | namespace PKISharp.SimplePKI.UnitTests
5 | {
6 | public static class OpenSsl
7 | {
8 | public const string OpenSslLightPath = @"C:\Program Files\OpenSSL\bin\openssl.exe";
9 |
10 | public static Process Start(string arguments)
11 | {
12 | if (File.Exists(OpenSslLightPath))
13 | {
14 | return Process.Start(OpenSslLightPath, arguments);
15 | }
16 | else
17 | {
18 | return Process.Start("openssl", arguments);
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/test/PKISharp.SimplePKI.UnitTests/PKISharp.SimplePKI.UnitTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/ACMEKestrel.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/test/ACMESharp.Testing.Xunit/TestDependencyAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ACMESharp.Testing.Xunit
4 | {
5 | [AttributeUsage(AttributeTargets.Method)]
6 | public sealed class TestDependencyAttribute : Attribute
7 | {
8 | /// the name of the test method (Fact)
9 | /// that is a dependency.
10 | public TestDependencyAttribute(string methodName)
11 | {
12 | MethodName = methodName;
13 | }
14 |
15 | ///
16 | /// The name of the test method (Fact) that is a dependency.
17 | ///
18 | public string MethodName { get; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/src/PKISharp.SimplePKI/PkiAsymmetricAlgorithm.cs:
--------------------------------------------------------------------------------
1 | namespace PKISharp.SimplePKI
2 | {
3 | public enum PkiAsymmetricAlgorithm
4 | {
5 | Unknown = 0,
6 |
7 | ///
8 | /// RSA (Rivest–Shamir–Adleman) is one of the first public-key cryptosystems
9 | /// and is widely used for secure data transmission.
10 | ///
11 | Rsa = 1,
12 |
13 | ///
14 | /// The Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant
15 | /// of the Digital Signature Algorithm (DSA) which uses elliptic curve
16 | /// cryptography.
17 | ///
18 | Ecdsa = 2,
19 | }
20 | }
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/lib/jquery/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "main": "dist/jquery.js",
4 | "license": "MIT",
5 | "ignore": [
6 | "package.json"
7 | ],
8 | "keywords": [
9 | "jquery",
10 | "javascript",
11 | "browser",
12 | "library"
13 | ],
14 | "homepage": "https://github.com/jquery/jquery-dist",
15 | "version": "3.3.1",
16 | "_release": "3.3.1",
17 | "_resolution": {
18 | "type": "version",
19 | "tag": "3.3.1",
20 | "commit": "9e8ec3d10fad04748176144f108d7355662ae75e"
21 | },
22 | "_source": "https://github.com/jquery/jquery-dist.git",
23 | "_target": "^3.3.1",
24 | "_originalSource": "jquery",
25 | "_direct": true
26 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Crypto/JOSE/IJwsTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace ACMESharp.Crypto.JOSE
5 | {
6 | ///
7 | /// Defines the interface for a tool that provides the required
8 | /// JOSE Web Signature (JWS) functions as used by the ACME protocol.
9 | ///
10 | public interface IJwsTool : IDisposable
11 | {
12 | string JwsAlg
13 | { get; }
14 |
15 | void Init();
16 |
17 | string Export();
18 |
19 | void Import(string exported);
20 |
21 | object ExportJwk(bool canonical = false);
22 |
23 | byte[] Sign(byte[] raw);
24 |
25 | bool Verify(byte[] raw, byte[] sig);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/Storage/BlazorOrder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using ACMESharp.Protocol;
7 | using ACMESharp.Protocol.Resources;
8 |
9 | namespace ACMEBlazor.Storage
10 | {
11 | public class BlazorOrder
12 | {
13 | public int Id { get; set; }
14 |
15 | public string DnsNames { get; set; }
16 |
17 | [Required]
18 | public BlazorAccount Account { get; set; }
19 |
20 | [Required]
21 | public OrderDetails Details { get; set; }
22 |
23 | public BlazorAuthorization[] Authorizations { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/wwwroot/sample-data/weather.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "date": "2018-05-06",
4 | "temperatureC": 1,
5 | "summary": "Freezing",
6 | "temperatureF": 33
7 | },
8 | {
9 | "date": "2018-05-07",
10 | "temperatureC": 14,
11 | "summary": "Bracing",
12 | "temperatureF": 57
13 | },
14 | {
15 | "date": "2018-05-08",
16 | "temperatureC": -13,
17 | "summary": "Freezing",
18 | "temperatureF": 9
19 | },
20 | {
21 | "date": "2018-05-09",
22 | "temperatureC": -16,
23 | "summary": "Balmy",
24 | "temperatureF": 4
25 | },
26 | {
27 | "date": "2018-05-10",
28 | "temperatureC": -2,
29 | "summary": "Chilly",
30 | "temperatureF": 29
31 | }
32 | ]
33 |
--------------------------------------------------------------------------------
/src/ACMESharp/Crypto/JOSE/JwsSignedPayload.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace ACMESharp.Crypto.JOSE
4 | {
5 | public class JwsSignedPayload
6 | {
7 | [JsonProperty("header", NullValueHandling = NullValueHandling.Ignore)]
8 | public object Header
9 | { get; set; }
10 |
11 | [JsonProperty("protected", NullValueHandling = NullValueHandling.Ignore)]
12 | public string Protected
13 | { get; set; }
14 |
15 | [JsonProperty("payload", Required = Required.Always)]
16 | public string Payload
17 | { get; set; }
18 |
19 | [JsonProperty("signature", Required = Required.Always)]
20 | public string Signature
21 | { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/examples/ACMEForms/Storage/DbAuthz.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ACMESharp.Authorizations;
7 | using ACMESharp.Protocol.Resources;
8 |
9 | namespace ACMEForms.Storage
10 | {
11 | public class DbAuthz
12 | {
13 | public int Id { get; set; }
14 |
15 | public string Url { get; set; }
16 |
17 | public Authorization Details { get; set; }
18 |
19 | public Dns01ChallengeValidationDetails DnsChallenge { get; set; }
20 |
21 | public Http01ChallengeValidationDetails HttpChallenge { get; set; }
22 |
23 | public Challenge[] MiscChallenges { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/ACMESharp.MockServer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace ACMESharp.MockServer
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | CreateWebHostBuilder(args).Build().Run();
18 | }
19 |
20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21 | WebHost.CreateDefaultBuilder(args)
22 | .UseStartup();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/Pages/Error.cshtml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.AspNetCore.Mvc.RazorPages;
8 |
9 | namespace ACMEKestrel.Pages
10 | {
11 | public class ErrorModel : PageModel
12 | {
13 | public string RequestId { get; set; }
14 |
15 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
16 |
17 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
18 | public void OnGet()
19 | {
20 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/examples/ACMEForms/Storage/DbOrder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ACMESharp.Protocol;
7 | using ACMESharp.Protocol.Resources;
8 |
9 | namespace ACMEForms.Storage
10 | {
11 | public class DbOrder
12 | {
13 | public int Id { get; set; }
14 |
15 | ///
16 | /// We cache the first Order URL we get because subsequent
17 | /// refreshes of the Order don't return it in the response.
18 | ///
19 | public string FirstOrderUrl { get; set; }
20 |
21 | public OrderDetails Details { get; set; }
22 |
23 | public DbAuthz[] Authorizations { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/AccountDetails.cs:
--------------------------------------------------------------------------------
1 | using ACMESharp.Protocol.Resources;
2 |
3 | namespace ACMESharp.Protocol
4 | {
5 | ///
6 | /// An aggregation of Account details including resource payload and ancillary,
7 | /// associated data.
8 | ///
9 | ///
10 | /// This represents a superset of details that are included in responses
11 | /// to several ACME operations regarding an ACME Account, such as Account
12 | /// registration, update, key rotation and deactivation.
13 | ///
14 | public class AccountDetails
15 | {
16 | public Account Payload { get; set; }
17 |
18 | public string Kid { get; set; }
19 |
20 | public string TosLink { get; set; }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Authorizations/Dns01ChallengeValidationDetails.cs:
--------------------------------------------------------------------------------
1 | namespace ACMESharp.Authorizations
2 | {
3 | ///
4 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-8.4
5 | ///
6 | public class Dns01ChallengeValidationDetails : IChallengeValidationDetails
7 | {
8 | public const string Dns01ChallengeType = "dns-01";
9 | public const string DnsRecordNamePrefix = "_acme-challenge";
10 | public const string DnsRecordTypeDefault = "TXT";
11 |
12 | public string ChallengeType => Dns01ChallengeType;
13 |
14 | public string DnsRecordName { get; set; }
15 |
16 | public string DnsRecordType { get; set; }
17 |
18 | public string DnsRecordValue { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/Storage/BlazorAccount.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using ACMESharp.Protocol;
7 |
8 | namespace ACMEBlazor.Storage
9 | {
10 | public class BlazorAccount
11 | {
12 | public int Id { get; set; }
13 |
14 | public string Contacts { get; set; }
15 |
16 | [Required]
17 | public string[] ContactEmails { get; set; }
18 |
19 | [Required]
20 | public DateTime? TosAgreed { get; set; }
21 |
22 | [Required]
23 | public string SignerExport { get; set; }
24 |
25 | [Required]
26 | public AccountDetails Details { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/ACMESharp.UnitTests/ACMESharp.UnitTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/BlazorStorageExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Blazor.Extensions;
6 | using Microsoft.AspNetCore.Blazor.Browser.Interop;
7 |
8 | namespace ACMEBlazor
9 | {
10 | // Temporary fix until this is merged in:
11 | // https://github.com/BlazorExtensions/Storage/pull/5
12 | public static class BlazorStorageExtensions
13 | {
14 | public const string LENGTH_METHOD = "Blazor.Extensions.Storage.Length";
15 | public const string LOCAL_STORAGE = "localStorage";
16 |
17 | public static int GetLength(this LocalStorage local)
18 | {
19 | return RegisteredFunction.Invoke(LENGTH_METHOD, LOCAL_STORAGE);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/examples/ACMEForms/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 | using ACMEForms.Storage;
7 | using ACMESharp.Protocol;
8 | using LiteDB;
9 |
10 | namespace ACMEForms
11 | {
12 | static class Program
13 | {
14 | public static Repository Repo { get; private set; }
15 |
16 | ///
17 | /// The main entry point for the application.
18 | ///
19 | [STAThread]
20 | static void Main()
21 | {
22 | Repo = Repository.GetInstance();
23 |
24 | Application.EnableVisualStyles();
25 | Application.SetCompatibleTextRenderingDefault(false);
26 | Application.Run(new MainForm());
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/AppState.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using ACMEBlazor.Storage;
6 |
7 | namespace ACMEBlazor
8 | {
9 | public class AppState
10 | {
11 | public static readonly string AccountKey = $"{nameof(ACMEBlazor)}-{nameof(BlazorAccount)}";
12 | public static readonly string OrderKey = $"{nameof(ACMEBlazor)}-{nameof(BlazorOrder)}:";
13 |
14 | public static readonly char[] LineSeps = "\r\n".ToCharArray();
15 |
16 | public static readonly BlazorAccount[] EmptyAccounts = new BlazorAccount[0];
17 | public static readonly BlazorOrder[] EmptyOrders = new BlazorOrder[0];
18 |
19 | public BlazorAccount Account { get; set; }
20 |
21 | public BlazorOrder[] Orders { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/Storage/BlazorAuthorization.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using ACMESharp.Authorizations;
7 | using ACMESharp.Protocol.Resources;
8 |
9 | namespace ACMEBlazor.Storage
10 | {
11 | public class BlazorAuthorization
12 | {
13 | public int Id { get; set; }
14 |
15 | //[Required]
16 | //public BlazorOrder Order { get; set; }
17 |
18 | [Required]
19 | public string Url { get; set; }
20 |
21 | [Required]
22 | public Authorization Details { get; set; }
23 |
24 | public Dns01ChallengeValidationDetails DnsChallengeDetails { get; set; }
25 |
26 | public Http01ChallengeValidationDetails HttpChallengeDetails { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Messages/CreateOrderRequest.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using ACMESharp.Crypto.JOSE;
3 | using ACMESharp.Protocol.Resources;
4 | using Newtonsoft.Json;
5 |
6 | namespace ACMESharp.Protocol.Messages
7 | {
8 | ///
9 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.4
10 | ///
11 | public class CreateOrderRequest
12 | {
13 | [JsonProperty("identifiers", Required = Required.Always)]
14 | [Required, MinLength(1)]
15 | public Identifier[] Identifiers { get; set; }
16 |
17 | [JsonProperty("notBefore", NullValueHandling = NullValueHandling.Ignore)]
18 | public string NotBefore { get; set; }
19 |
20 | [JsonProperty("notAfter", NullValueHandling = NullValueHandling.Ignore)]
21 | public string NotAfter { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/examples/ACMECLI/ACMECLI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | LATEST
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "ACMECLI",
4 | "Algor",
5 | "CNAME",
6 | "Canonicalize",
7 | "ECDSA",
8 | "PKCS",
9 | "UPSERT",
10 | "Xunit",
11 | "acmesharp",
12 | "acmesharpcore",
13 | "authz",
14 | "bkkr",
15 | "blockrdp",
16 | "chlng",
17 | "choco",
18 | "dd'T'HH",
19 | "deserializes",
20 | "dpkg",
21 | "finalizer",
22 | "integtests",
23 | "ldconfig",
24 | "mailto",
25 | "mkdir",
26 | "msbuild",
27 | "myapp",
28 | "mycertificate",
29 | "nist",
30 | "nupkg",
31 | "openssl",
32 | "popd",
33 | "pushd",
34 | "pwsh",
35 | "requ",
36 | "stateful",
37 | "uncomment",
38 | "wasapl",
39 | "webclient",
40 | "zyborg"
41 | ]
42 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Resources/Authorization.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using Newtonsoft.Json;
3 |
4 | namespace ACMESharp.Protocol.Resources
5 | {
6 | ///
7 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.1.4
8 | ///
9 | public class Authorization
10 | {
11 | [JsonProperty("identifier", Required = Required.Always)]
12 | [Required]
13 | public Identifier Identifier { get; set; }
14 |
15 | [JsonProperty("status", Required = Required.Always)]
16 | [Required]
17 | public string Status { get; set; }
18 |
19 | [JsonProperty("expires")]
20 | public string Expires { get; set; }
21 |
22 | [JsonProperty("challenges")]
23 | [Required]
24 | public Challenge[] Challenges { get; set; }
25 |
26 | [JsonProperty("wildcard")]
27 | public bool? Wildcard { get; set; }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/Pages/Error.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model ErrorModel
3 | @{
4 | ViewData["Title"] = "Error";
5 | }
6 |
7 |
Error.
8 |
An error occurred while processing your request.
9 |
10 | @if (Model.ShowRequestId)
11 | {
12 |
13 | Request ID:@Model.RequestId
14 |
15 | }
16 |
17 |
Development Mode
18 |
19 | Swapping to Development environment will display more detailed information about the error that occurred.
20 |
21 |
22 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.
23 |
24 |
--------------------------------------------------------------------------------
/src/ACMESharp/Authorizations/Http01ChallengeValidationDetails.cs:
--------------------------------------------------------------------------------
1 | namespace ACMESharp.Authorizations
2 | {
3 | ///
4 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-8.3
5 | ///
6 | public class Http01ChallengeValidationDetails : IChallengeValidationDetails
7 | {
8 | public const string Http01ChallengeType = "http-01";
9 | // URL template:
10 | // "http://{domain}/.well-known/acme-challenge/{token}"
11 | public const string HttpPathPrefix = ".well-known/acme-challenge";
12 | public const string HttpResourceContentTypeDefault = "application/octet-stream";
13 |
14 | public string ChallengeType => Http01ChallengeType;
15 |
16 | public string HttpResourceUrl { get; set; }
17 |
18 | public string HttpResourcePath { get; set; }
19 |
20 | public string HttpResourceContentType { get; set; }
21 |
22 | public string HttpResourceValue { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Resources/ProblemType.cs:
--------------------------------------------------------------------------------
1 | namespace ACMESharp.Protocol.Resources
2 | {
3 | ///
4 | /// Defines standard ACME errors.
5 | ///
6 | ///
7 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-18#section-6.7
8 | ///
9 | public enum ProblemType
10 | {
11 | Unknown = 0,
12 |
13 | AccountDoesNotExist,
14 | AlreadyRevoked,
15 | BadCSR,
16 | BadNonce,
17 | BadRevocationReason,
18 | BadSignatureAlgorithm,
19 | Caa,
20 | Compound,
21 | Connection,
22 | Dns,
23 | ExternalAccountRequired,
24 | IncorrectResponse,
25 | InvalidContact,
26 | Malformed,
27 | RateLimited,
28 | RejectedIdentifier,
29 | ServerInternal,
30 | Tls,
31 | Unauthorized,
32 | UnsupportedContact,
33 | UnsupportedIdentifier,
34 | UserActionRequired,
35 | }
36 | }
--------------------------------------------------------------------------------
/test/ACMESharp.IntegrationTests/AwsFixture.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Newtonsoft.Json;
3 |
4 | namespace ACMESharp.IntegrationTests
5 | {
6 | public class AwsFixture
7 | {
8 | public AwsFixture()
9 | {
10 | var thisAsmLocation = Path.GetDirectoryName(typeof(AwsFixture).Assembly.Location);
11 | var jsonPathBase = Path.Combine(thisAsmLocation, @"config/_IGNORE/");
12 |
13 | R53 = JsonConvert.DeserializeObject(
14 | File.ReadAllText(jsonPathBase + "R53Helper.json"));
15 | S3 = JsonConvert.DeserializeObject(
16 | File.ReadAllText(jsonPathBase + "S3Helper.json"));
17 |
18 | // For testing this makes it easier to repeat tests
19 | // that use the same DNS names and need to be refreshed
20 | R53.DnsRecordTtl = 60;
21 | }
22 |
23 | public R53Helper R53 { get; }
24 |
25 | public S3Helper S3 { get; }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Logging/NullLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.Logging;
3 |
4 | namespace ACMESharp.Logging
5 | {
6 | ///
7 | /// Implementation of the logger interface that does nothing.
8 | ///
9 | ///
10 | /// Provides a default, do-nothing implementation.
11 | ///
12 | public class NullLogger : ILogger
13 | {
14 | public static readonly NullLogger Instance = new NullLogger();
15 |
16 | public bool IsEnabled(LogLevel logLevel) => false;
17 |
18 | public IDisposable BeginScope(TState state) => new NullLoggerScope();
19 |
20 | public void Log(LogLevel logLevel, EventId eventId, TState state,
21 | Exception exception, Func formatter)
22 | { }
23 |
24 | public class NullLoggerScope : IDisposable
25 | {
26 | public void Dispose()
27 | { }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/examples/ACMEForms/Storage/DbAccount.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using ACMESharp.Protocol;
7 |
8 | namespace ACMEForms.Storage
9 | {
10 | public class DbAccount
11 | {
12 | public static readonly IEnumerable> WellKnownAcmeServers =
13 | new (string key, string label)[]
14 | {
15 | ("https://acme-staging-v02.api.letsencrypt.org/", "Let's Encrypt v2 STAGE"),
16 | ("https://acme-v02.api.letsencrypt.org/", "Let's Encrypt v2"),
17 | (string.Empty, "(CUSTOM)"),
18 | }.Select(x => new KeyValuePair(x.key, x.label));
19 |
20 | public string AcmeServerEndpoint { get; set; }
21 |
22 | public int Id { get; set; }
23 |
24 | public string JwsSigner { get; set; }
25 |
26 | public AccountDetails Details { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 | body {
4 | padding-top: 50px;
5 | padding-bottom: 20px;
6 | }
7 |
8 | /* Wrapping element */
9 | /* Set some basic padding to keep content from hitting the edges */
10 | .body-content {
11 | padding-left: 15px;
12 | padding-right: 15px;
13 | }
14 |
15 | /* Carousel */
16 | .carousel-caption p {
17 | font-size: 20px;
18 | line-height: 1.4;
19 | }
20 |
21 | /* Make .svg files in the carousel display properly in older browsers */
22 | .carousel-inner .item img[src$=".svg"] {
23 | width: 100%;
24 | }
25 |
26 | /* QR code generator */
27 | #qrCode {
28 | margin: 15px;
29 | }
30 |
31 | /* Hide/rearrange for smaller screens */
32 | @media screen and (max-width: 767px) {
33 | /* Hide captions */
34 | .carousel-caption {
35 | display: none;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/test/ACMESharp.MockServer.UnitTests/ACMESharp.MockServer.UnitTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test/ACMESharp.Testing.Xunit/TestOrderAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ACMESharp.Testing.Xunit
4 | {
5 | ///
6 | /// Declares a relative test ordering weight. Can be applied to individual
7 | /// test methods (test facts) or classes (test collections).
8 | ///
9 | ///
10 | /// To be used only for non-unit-tests such as integration tests
11 | /// where the exact order of individual tests is significant due to dependencies
12 | /// between tests.
13 | ///
14 | /// To use this attribute, you must use the custom
15 | /// test ordering support.
16 | ///
17 | ///
18 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
19 | public sealed class TestOrderAttribute : Attribute
20 | {
21 | public TestOrderAttribute(int order, string group = null)
22 | {
23 | Order = order;
24 | Group = group;
25 | }
26 |
27 | public int Order { get; }
28 |
29 | public string Group { get; }
30 | }
31 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 PKISharp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/lib/jquery-validation/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation",
3 | "homepage": "https://jqueryvalidation.org/",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/jquery-validation/jquery-validation.git"
7 | },
8 | "authors": [
9 | "Jörn Zaefferer "
10 | ],
11 | "description": "Form validation made easy",
12 | "main": "dist/jquery.validate.js",
13 | "keywords": [
14 | "forms",
15 | "validation",
16 | "validate"
17 | ],
18 | "license": "MIT",
19 | "ignore": [
20 | "**/.*",
21 | "node_modules",
22 | "bower_components",
23 | "test",
24 | "demo",
25 | "lib"
26 | ],
27 | "dependencies": {
28 | "jquery": ">= 1.7.2"
29 | },
30 | "version": "1.17.0",
31 | "_release": "1.17.0",
32 | "_resolution": {
33 | "type": "version",
34 | "tag": "1.17.0",
35 | "commit": "fc9b12d3bfaa2d0c04605855b896edb2934c0772"
36 | },
37 | "_source": "https://github.com/jzaefferer/jquery-validation.git",
38 | "_target": "^1.17.0",
39 | "_originalSource": "jquery-validation",
40 | "_direct": true
41 | }
--------------------------------------------------------------------------------
/src/ACMESharp.MockServer/RepoNonceManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ACMESharp.MockServer.Storage;
3 |
4 | namespace ACMESharp.MockServer
5 | {
6 | public class RepoNonceManager : INonceManager
7 | {
8 | private IRepository _repo;
9 |
10 | public RepoNonceManager(IRepository repo)
11 | {
12 | _repo = repo;
13 | }
14 | public string GenerateNonce()
15 | {
16 | var nonce = new DbNonce
17 | {
18 | Nonce = Guid.NewGuid().ToString(),
19 | };
20 | _repo.SaveNonce(nonce);
21 | return nonce.Nonce;
22 | }
23 |
24 | public bool PeekNonce(string nonce)
25 | {
26 | var dbNonce = _repo.GetNonceByValue(nonce);
27 | return dbNonce != null;
28 | }
29 |
30 | public bool ValidateNonce(string nonce)
31 | {
32 | var dbNonce = _repo.GetNonceByValue(nonce);
33 | if (dbNonce == null)
34 | return false;
35 |
36 | _repo.RemoveNonce(dbNonce);
37 | return true;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Messages/CreateAccountRequest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 | using ACMESharp.Crypto.JOSE;
4 | using Newtonsoft.Json;
5 |
6 | namespace ACMESharp.Protocol.Messages
7 | {
8 | ///
9 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3
10 | ///
11 | public class CreateAccountRequest
12 | {
13 | [JsonProperty("contact", Required = Required.Always)]
14 | [Required, MinLength(1)]
15 | public IEnumerable Contact { get; set; }
16 |
17 | [JsonProperty("termsOfServiceAgreed", NullValueHandling=NullValueHandling.Ignore)]
18 | public bool? TermsOfServiceAgreed { get; set; }
19 |
20 | [JsonProperty("onlyReturnExisting", NullValueHandling=NullValueHandling.Ignore)]
21 | public bool? OnlyReturnExisting { get; set; }
22 |
23 | [JsonProperty("externalAccountBinding", NullValueHandling=NullValueHandling.Ignore)]
24 | public object ExternalAccountBinding { get; set; }
25 | //public JwsSignedPayload ExternalAccountBinding { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/lib/bootstrap/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap",
3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
4 | "keywords": [
5 | "css",
6 | "js",
7 | "less",
8 | "mobile-first",
9 | "responsive",
10 | "front-end",
11 | "framework",
12 | "web"
13 | ],
14 | "homepage": "http://getbootstrap.com",
15 | "license": "MIT",
16 | "moduleType": "globals",
17 | "main": [
18 | "less/bootstrap.less",
19 | "dist/js/bootstrap.js"
20 | ],
21 | "ignore": [
22 | "/.*",
23 | "_config.yml",
24 | "CNAME",
25 | "composer.json",
26 | "CONTRIBUTING.md",
27 | "docs",
28 | "js/tests",
29 | "test-infra"
30 | ],
31 | "dependencies": {
32 | "jquery": "1.9.1 - 3"
33 | },
34 | "version": "3.3.7",
35 | "_release": "3.3.7",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.3.7",
39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86"
40 | },
41 | "_source": "https://github.com/twbs/bootstrap.git",
42 | "_target": "v3.3.7",
43 | "_originalSource": "bootstrap",
44 | "_direct": true
45 | }
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Resources/Account.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using Newtonsoft.Json;
5 |
6 | namespace ACMESharp.Protocol.Resources
7 | {
8 | ///
9 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.1.2
10 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3
11 | ///
12 | public class Account
13 | {
14 | public string Id { get; set; }
15 |
16 | public object Key { get; set; }
17 |
18 | public string[] Contact { get; set; }
19 |
20 | public string Status { get; set; }
21 |
22 | public bool? TermsOfServiceAgreed { get; set; }
23 |
24 | public string Orders { get; set; }
25 |
26 | // TODO: are these standard or specific to LE?
27 | // "agreement": "https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf",
28 | // "initialIp": "50.235.30.49",
29 | // "createdAt": "2018-05-02T22:23:30Z",
30 | public string InitialIp { get; set; }
31 | public string CreatedAt { get; set; }
32 | public string Agreement { get; set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2016 Twitter, Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27703.2026
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ACMEBlazor", "ACMEBlazor\ACMEBlazor.csproj", "{B94A1327-02ED-4214-8B57-7F5A5AE022D2}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B94A1327-02ED-4214-8B57-7F5A5AE022D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B94A1327-02ED-4214-8B57-7F5A5AE022D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B94A1327-02ED-4214-8B57-7F5A5AE022D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B94A1327-02ED-4214-8B57-7F5A5AE022D2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {15827651-06A5-40F4-9947-18338AB228A8}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/src/examples/Examples.Common.PKI/ExamplesAccountKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using ACMESharp.Crypto.JOSE;
5 |
6 | namespace Examples.Common.PKI
7 | {
8 | public class ExamplesAccountKey
9 | {
10 | public string KeyType { get; set; }
11 | public string KeyExport { get; set; }
12 |
13 | public IJwsTool GenerateTool()
14 | {
15 | if (KeyType.StartsWith("ES"))
16 | {
17 | var tool = new ACMESharp.Crypto.JOSE.Impl.ESJwsTool();
18 | tool.HashSize = int.Parse(KeyType.Substring(2));
19 | tool.Init();
20 | tool.Import(KeyExport);
21 | return tool;
22 | }
23 |
24 | if (KeyType.StartsWith("RS"))
25 | {
26 | var tool = new ACMESharp.Crypto.JOSE.Impl.RSJwsTool();
27 | tool.HashSize = int.Parse(KeyType.Substring(2));
28 | tool.Init();
29 | tool.Import(KeyExport);
30 | return tool;
31 | }
32 |
33 | throw new Exception($"Unknown or unsupported KeyType [{KeyType}]");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/ACMESharp.MockServer/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace ACMESharp.MockServer.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class ValuesController : ControllerBase
12 | {
13 | // GET api/values
14 | [HttpGet]
15 | public ActionResult> Get()
16 | {
17 | return new string[] { "value1", "value2" };
18 | }
19 |
20 | // GET api/values/5
21 | [HttpGet("{id}")]
22 | public ActionResult Get(int id)
23 | {
24 | return "value";
25 | }
26 |
27 | // POST api/values
28 | [HttpPost]
29 | public void Post([FromBody] string value)
30 | {
31 | }
32 |
33 | // PUT api/values/5
34 | [HttpPut("{id}")]
35 | public void Put(int id, [FromBody] string value)
36 | {
37 | }
38 |
39 | // DELETE api/values/5
40 | [HttpDelete("{id}")]
41 | public void Delete(int id)
42 | {
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/examples/ACMEForms/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ACMEForms.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/examples/ACMEKestrel/Pages/Shared/_ValidationScriptsPartial.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
12 |
18 |
19 |
--------------------------------------------------------------------------------
/test/ACMESharp.IntegrationTests/XunitDebugging/import.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | <_XunitTargetFrameworksLines Include="$(TargetFramework)" />
6 |
7 |
8 | <_XunitTargetFrameworksLines Include="$(TargetFrameworks)" />
9 |
10 |
11 |
12 |
13 |
14 | <_XunitInfoLines Include="OutputPath: $(OutputPath)"/>
15 | <_XunitInfoLines Include="AssemblyName: $(AssemblyName)"/>
16 | <_XunitInfoLines Include="TargetFileName: $(TargetFileName)"/>
17 | <_XunitInfoLines Include="TargetFrameworkIdentifier: $(TargetFrameworkIdentifier)"/>
18 | <_XunitInfoLines Include="TargetFrameworkVersion: $(TargetFrameworkVersion)"/>
19 | <_XunitInfoLines Include="RuntimeFrameworkVersion: $(RuntimeFrameworkVersion)"/>
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/ACMESharp.IntegrationTests/XunitDebugging/ArgParser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ACMESharp.IntegrationTests.Debugging
5 | {
6 | public static class ArgParser
7 | {
8 | // Simple argument parser that doesn't do much validation, since we will rely on the inner
9 | // runners to do the argument validation.
10 | public static Dictionary> Parse(string[] args)
11 | {
12 | var result = new Dictionary>(StringComparer.OrdinalIgnoreCase);
13 | var idx = 0;
14 |
15 | while (idx < args.Length)
16 | {
17 | var arg = args[idx++];
18 | if (!arg.StartsWith("-"))
19 | throw new ArgumentException($"Unexpected parameter: {arg}");
20 |
21 | if (!result.TryGetValue(arg, out var values))
22 | {
23 | values = new List();
24 | result.Add(arg, values);
25 | }
26 |
27 | if (idx < args.Length && !args[idx].StartsWith("-"))
28 | values.Add(args[idx++]);
29 | else
30 | values.Add(null);
31 | }
32 |
33 | return result;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/tools/test-report/sample-test-results.ps1:
--------------------------------------------------------------------------------
1 |
2 | #$xslFile = "$PSScriptRoot\example.xsl"
3 | #$xmlFile = "$PSScriptRoot\example.xml"
4 | #$outFile = "$PSScriptRoot\example.out"
5 |
6 | $xslFile = "$PSScriptRoot\trx2md.xsl"
7 | $xmlFile = "$PSScriptRoot\sample-test-results.trx"
8 | $outFile = "$PSScriptRoot\sample-test.results.md"
9 |
10 | class TrxFn {
11 | [double]DiffSeconds([datetime]$from, [datetime]$till) {
12 | return ($till - $from).TotalSeconds
13 | }
14 | }
15 |
16 |
17 | if (-not $script:xslt) {
18 | $script:urlr = [System.Xml.XmlUrlResolver]::new()
19 | $script:opts = [System.Xml.Xsl.XsltSettings]::new()
20 | #$script:opts.EnableScript = $true
21 | $script:xslt = [System.Xml.Xsl.XslCompiledTransform]::new()
22 | try {
23 | $script:xslt.Load($xslFile, $script:opts, $script:urlr)
24 | }
25 | catch {
26 | $Error[0]
27 | return
28 | }
29 | }
30 |
31 | $script:list = [System.Xml.Xsl.XsltArgumentList]::new()
32 | $script:list.AddExtensionObject("urn:trxfn", [TrxFn]::new())
33 | $script:wrtr = [System.IO.StreamWriter]::new($outFile)
34 | try {
35 | $script:xslt.Transform(
36 | [string]$xmlFile,
37 | [System.Xml.Xsl.XsltArgumentList]$script:list,
38 | [System.IO.TextWriter]$script:wrtr)
39 | }
40 | finally {
41 | $script:wrtr.Dispose()
42 | }
43 |
--------------------------------------------------------------------------------
/src/ACMESharp/Protocol/Messages/UpdateAccountRequest.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 | using ACMESharp.Crypto.JOSE;
4 | using Newtonsoft.Json;
5 |
6 | namespace ACMESharp.Protocol.Messages
7 | {
8 | ///
9 | /// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3
10 | ///
11 | public class UpdateAccountRequest
12 | {
13 | ///
14 | /// The list of contact URLs. Although a request to create a brand new account
15 | /// requires this value, when used in a request to lookup an existing account
16 | /// this property can be omitted.
17 | ///
18 | [JsonProperty("contact", NullValueHandling=NullValueHandling.Ignore)]
19 | public IEnumerable Contact { get; set; }
20 |
21 | [JsonProperty("termsOfServiceAgreed", NullValueHandling=NullValueHandling.Ignore)]
22 | public bool? TermsOfServiceAgreed { get; set; }
23 |
24 | [JsonProperty("externalAccountBinding", NullValueHandling=NullValueHandling.Ignore)]
25 | public object ExternalAccountBinding { get; set; }
26 | //public JwsSignedPayload ExternalAccountBinding { get; set; }
27 |
28 | [JsonProperty("status", NullValueHandling=NullValueHandling.Ignore)]
29 | public string Status { get; set; }
30 | }
31 | }
--------------------------------------------------------------------------------
/tools/chocoInstallDotNetCore21Rc1.ps1:
--------------------------------------------------------------------------------
1 | $ErrorActionPreference = 'Stop';
2 |
3 | ipmo "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1"
4 |
5 | $packageName= 'dotnetcore-sdk'
6 | $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
7 | #$url = 'https://download.microsoft.com/download/D/7/8/D788D3CD-44C4-487D-829B-413E914FB1C3/dotnet-sdk-2.1.300-preview1-008174-win-x86.exe'
8 | #$checksum = 'bd8a9145f651026cfa1ca7c264c2e05b3740afc0b5f8ac5572409a95836d8f87e1a8c460eb985182501f679b721a97fd174b7690ab8cdc5e43c8155ee8af94b5'
9 | $url64 = 'https://download.microsoft.com/download/B/1/9/B19A2F87-F00F-420C-B4B9-A0BA4403F754/dotnet-sdk-2.1.300-rc1-008673-win-x64.exe'
10 | $checksum64 = '7256aca2c02827028213ce06ceb5414231b01bbc509d0d57d5258106760c0fa5621a9d5f629fca3f34d6c45523a133206561d7188a0cb4817d4d5cc6c172d6f0'
11 |
12 | $packageArgs = @{
13 | packageName = $packageName
14 | unzipLocation = $toolsDir
15 | fileType = 'EXE'
16 | url = $url
17 | url64bit = $url64
18 |
19 | silentArgs = "/install /quiet /norestart /log `"$env:TEMP\$($packageName)\$($packageName).MsiInstall.log`""
20 | validExitCodes= @(0, 3010, 1641)
21 |
22 | softwareName = 'dotnet-core*'
23 | checksum = $checksum
24 | checksumType = 'SHA512'
25 | checksum64 = $checksum64
26 | }
27 |
28 | Install-ChocolateyPackage @packageArgs
29 |
--------------------------------------------------------------------------------
/src/examples/ACMECLI/HttpUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Net.Http;
4 | using System.Threading.Tasks;
5 |
6 | namespace ACMECLI
7 | {
8 | public static class HttpUtil
9 | {
10 | private static HttpClient _Client;
11 |
12 | public static HttpClient Client
13 | {
14 | get
15 | {
16 | if (_Client == null)
17 | {
18 | lock(typeof(HttpUtil))
19 | {
20 | if (_Client == null)
21 | {
22 | _Client = new HttpClient();
23 | }
24 | }
25 | }
26 | return _Client;
27 | }
28 | }
29 |
30 | public static async Task GetStringAsync(string url)
31 | {
32 | var resp = await Client.GetAsync(url);
33 |
34 | if (resp.StatusCode != HttpStatusCode.OK)
35 | {
36 | if (resp.StatusCode == HttpStatusCode.NotFound)
37 | return null;
38 | throw new Exception("HTTP request error: "
39 | + $"({resp.StatusCode}) {await resp.Content.ReadAsStringAsync()}");
40 | }
41 |
42 | return await resp.Content.ReadAsStringAsync();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Crypto/CryptoHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Security.Cryptography;
4 | using System.Security.Cryptography.X509Certificates;
5 | using Newtonsoft.Json;
6 | using System.Collections.Generic;
7 |
8 | namespace ACMESharp.Crypto
9 | {
10 | ///
11 | /// For the most compatibility with LE, see:
12 | /// https://letsencrypt.org/docs/integration-guide/#supported-key-algorithms
13 | /// We should support:
14 | /// * RSA Keys (2048-4096 bits)
15 | /// * ECDSA Keys (P-256, P-384)
16 | ///
17 | /// Thats' for both account keys and cert keys.
18 | ///
19 | public static class CryptoHelper
20 | {
21 | ///
22 | /// Returns a singleton instance of cryptographic tool
23 | /// for URL-safe Base64 encoding.
24 | ///
25 | public static Base64Tool Base64 { get; } = new Base64Tool();
26 |
27 | ///
28 | /// Returns a singleton instance of cryptographic tool
29 | /// for working with RSA keys and algorithms.
30 | ///
31 | public static RsaTool Rsa { get; } = new RsaTool();
32 |
33 | ///
34 | /// Returns a singleton instance of cryptographic tool
35 | /// for working with EC keys and algorithms.
36 | ///
37 | public static EcTool Ec { get; } = new EcTool();
38 | }
39 | }
--------------------------------------------------------------------------------
/src/ACMESharp/Crypto/EcTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 |
4 | namespace ACMESharp.Crypto
5 | {
6 | ///
7 | /// Collection of convenient crypto operations working
8 | /// with Elliptic Curve keys and algorithms.
9 | ///
10 | public class EcTool
11 | {
12 | public ECDsa GenerateAlgorithm(int curveSize)
13 | {
14 | ECCurve curve;
15 | switch (curveSize)
16 | {
17 | case 256:
18 | curve = ECCurve.NamedCurves.nistP256;
19 | break;
20 | case 384:
21 | curve = ECCurve.NamedCurves.nistP384;
22 | break;
23 | default:
24 | throw new ArgumentOutOfRangeException("only 256 and 384 curves are supported");
25 | }
26 |
27 | return ECDsa.Create(curve);
28 | }
29 |
30 | public ECDsa GenerateAlgorithm(string ecKeys)
31 | {
32 | var dsa = ECDsa.Create();
33 | dsa.FromXmlString(ecKeys);
34 | return dsa;
35 | }
36 |
37 | public string GenerateKeys(int curveSize)
38 | {
39 | return GenerateKeys(GenerateAlgorithm(curveSize));
40 | }
41 |
42 | public string GenerateKeys(ECDsa ec)
43 | {
44 | return ec.ToXmlString(true);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/examples/ACMEBlazor/Pages/FetchData.cshtml:
--------------------------------------------------------------------------------
1 | @page "/fetchdata"
2 | @inject HttpClient Http
3 |
4 |
Weather forecast
5 |
6 |
This component demonstrates fetching data from the server.