Dynatrace / openkit-dotnet

OpenKit .NET Reference Implementation
Apache License 2.0
16 stars 16 forks source link

Ignoring SSL certificates #118

Closed pahofmann closed 4 years ago

pahofmann commented 4 years ago

The detailed example mentions a ISSLTrustManager can be used to allow untrusted SSL certificates.
Could you provide an example of the setup for the ISSLTrustManager and how to pass it to openkit?

stefaneberl commented 4 years ago

Hi Patrick!

Thank you for your question.

The ISSLTrustManager is the interface that can be passed to the DynatraceOpenKitBuilder as well as the AppMonOpenKitBuilder.

OpenKit offers two implementations

Example of how to use SSLBlindTrustManager

var openKit = new DynatraceOpenKitBuilder(BeaconEndpoint, CustomAppUuid, DeviceIdentifier)
    .WithApplicationVersion("1.0.0")
    .WithOperatingSystem(Environment.OSVersion.VersionString)
    .WithTrustManager(new SSLBlindTrustManager()) // this line overides the default SSLStrictTrustManager
    .WithDataCollectionLevel(DataCollectionLevel.USER_BEHAVIOR)
    .WithCrashReportingLevel(CrashReportingLevel.OPT_IN_CRASHES)
    .EnableVerbose()
    .Build();

If you want to implement your own SSLTrustManager, you'll need to implement the ISSLTrustManager interface, which consists of only one getter property, that returns an RemoteCertificateValidationCallback. Details about the RemoteCertificateValidationCallback can be found in the official Microsoft documentation https://docs.microsoft.com/en-us/dotnet/api/system.net.security.remotecertificatevalidationcallback?view=netcore-3.1

Best Stefan

pahofmann commented 4 years ago

Thank you very much vor the quick reply!