Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional skipSslCheck flag to Equinox.Cosmos.Connector #170

Merged
merged 3 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Equinox.Cosmos/Cosmos.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,9 @@ type Connector
[<O; D(null)>]?writeRetryPolicy,
/// Additional strings identifying the context of this connection; should provide enough context to disambiguate all potential connections to a cluster
/// NB as this will enter server and client logs, it should not contain sensitive information
[<O; D(null)>]?tags : (string*string) seq) =
[<O; D(null)>]?tags : (string*string) seq,
/// Skips SSL verification when set to true, i.e. for working with the CosmosDB Emulator (default false)
[<O; D(null)>]?skipSslCheck : bool) =
bartelink marked this conversation as resolved.
Show resolved Hide resolved
do if log = null then nullArg "log"

let clientOptions =
Expand All @@ -1107,7 +1109,13 @@ type Connector
yield name
match tags with None -> () | Some tags -> for key, value in tags do yield sprintf "%s=%s" key value }
let sanitizedName = name.Replace('\'','_').Replace(':','_') // sic; Align with logging for ES Adapter
let client = new Client.DocumentClient(uri, key, clientOptions, Nullable(defaultArg defaultConsistencyLevel ConsistencyLevel.Session))
let client =
bartelink marked this conversation as resolved.
Show resolved Hide resolved
match skipSslCheck with
| Some false | None ->
new Client.DocumentClient(uri, key, clientOptions, Nullable(defaultArg defaultConsistencyLevel ConsistencyLevel.Session))
| Some true ->
let noSslCheckHandler = new System.Net.Http.HttpClientHandler(ServerCertificateCustomValidationCallback = fun _ _ _ _ -> true)
new Client.DocumentClient(uri, key, noSslCheckHandler, clientOptions, Nullable(defaultArg defaultConsistencyLevel ConsistencyLevel.Session))
log.ForContext("Uri", uri).Information("CosmosDb Connection Name {connectionName}", sanitizedName)
do! client.OpenAsync() |> Async.AwaitTaskCorrect
return client }
Expand Down
4 changes: 2 additions & 2 deletions src/Equinox.Cosmos/Equinox.Cosmos.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

<PackageReference Include="FsCodec.NewtonsoftJson" Version="1.0.0-pr.20.rc2.5" />
<PackageReference Include="FSharp.Control.AsyncSeq" Version="2.0.21" />
<PackageReference Include="Microsoft.Azure.DocumentDB" Version="2.0.0" Condition=" '$(TargetFramework)' != 'netstandard2.0' " />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.0.0" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
<PackageReference Include="Microsoft.Azure.DocumentDB" Version="2.7.0" Condition=" '$(TargetFramework)' != 'netstandard2.0' " />
bartelink marked this conversation as resolved.
Show resolved Hide resolved
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.7.0" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
</ItemGroup>

</Project>