Comments (5)
The problem was TLS. by default Visual Studio is not using TLS12 as the first option.
Please change the constructor in Client.cs
to:
public Client(string endpoint = null, string applicationKey = null,
string applicationSecret = null, string consumerKey = null,
TimeSpan? defaultTimeout = null, char parameterSeparator = ',',
HttpClient httpClient = null, string confFileName = ".ovh.conf") : this()
{
LoadConfiguration(endpoint, applicationKey, applicationSecret, consumerKey, parameterSeparator, confFileName);
_defaultTimeout = defaultTimeout ?? _defaultTimeout;
//specify to use TLS 1.2 as default connection
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
_httpClient = httpClient ?? _httpClient ?? new HttpClient(handler);
}
from csharp-ovh.
Quick fix solution for the current version
Necessary references:
using System;
using Ovh.Api;
using System.Threading.Tasks;
using System.Net;
using System.Net.Http;
/// <summary>
/// Customise our client.
/// </summary>
/// <returns></returns>
internal static Client NoProxyClient()
{
//specify to use TLS 1.2 as default connection, otherwise it will not work...
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
//Remove Proxy, In my case we have a proxy in the LAN
HttpClientHandler handler = new HttpClientHandler
{
UseProxy = false
};
var httpClient = new HttpClient(handler);
return new Client(null,null,null,null,null,',',httpClient);
}
public static async Task<string> MyInfo()
{
Client client = NoProxyClient();
string me = await client.GetAsync("/me");
return me;
}
from csharp-ovh.
Hello,
Thanks for opening an issue, and for your investigation!
I could not reproduce on my side, using a .NET Core 3.1 console application running on Windows 10 20H2. Looking at the documentation, starting with .NET Framework 4.7, it seems this configuration depends on the system:
- Are you using an older framework?
- Are you using a Windows version that don't have it enabled?
In any case, ServicePointManager.SecurityProtocol
alters the whole process, therefore we should not manipulate it from inside the library as per Microsoft recommendations. However, you can apply that change in your own code if this is an acceptable solution for you.
from csharp-ovh.
I had the problem while debuging using Visual Studio 2017 in a windows 10 on a WebProject with for NetFramework 4.6.2.
The fault is probably because of the IIS Express used by VS in debug.
Just want to add that the code is clean and well comented, well done.
from csharp-ovh.
The problem is VS in debug mode using the IIS Express.
from csharp-ovh.
Related Issues (20)
- Add an IEnumerable API to ease subsequent calls HOT 1
- Object Storage API HOT 1
- Github documentation is obsolete. HOT 9
- Improve JSON parsing exception by sending back problematic string HOT 1
- WebClient not supporting concurrent I/O operations HOT 6
- Remove sync methods HOT 1
- Scope timeout to Ovh.Client instance
- Allow to give a timeout per call
- Replace all <T,Y> methods by <T> HOT 1
- Create releases directly on travis HOT 1
- No responses to any api calls HOT 9
- Dot Net Core 3.1, Can not find Ovh namespace. HOT 3
- No definition for "RequestConsumerKey" HOT 3
- Error logging? HOT 2
- Error Cannot deserialize the current JSON object into type 'System.Int64' HOT 3
- How do you change the provider in code without declaring a new client? HOT 2
- Unable to handle HTTP 204 correctly
- Add US endpoint
- Support for .NET Standard HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csharp-ovh.