C
C#β€’16mo ago
maria 🌟

❔ πŸ˜₯πŸ˜₯ HTTPlistener to doenst work with https

98 Replies
maria 🌟
maria πŸŒŸβ€’16mo ago
halp
Angius
Angiusβ€’16mo ago
Well you're only listening on http:// so Also, any errors?
maria 🌟
maria πŸŒŸβ€’16mo ago
I WANT HTTPS not http
Angius
Angiusβ€’16mo ago
Why do you listen on HTTP twice, then?
maria 🌟
maria πŸŒŸβ€’16mo ago
port compatibilty
Henkypenky
Henkypenkyβ€’16mo ago
you need a certificate for https
Angius
Angiusβ€’16mo ago
HttpListener Class (System.Net)
Provides a simple, programmatically controlled HTTP protocol listener. This class cannot be inherited.
Angius
Angiusβ€’16mo ago
And you need to actually listen on HTTPS Or better yet, depending on what you're trying to make, just use ASP
maria 🌟
maria πŸŒŸβ€’16mo ago
aspΒΏ?
Angius
Angiusβ€’16mo ago
Yes, the web framework for C# ASP.NET Core
maria 🌟
maria πŸŒŸβ€’16mo ago
And how i do it
Henkypenky
Henkypenkyβ€’16mo ago
i have no idea, also this is terribly outdated, we are talking windows xp here you can start by reading the doc ZZZ shared
Angius
Angiusβ€’16mo ago
I mean, HttpListener isn't outdated, it just has some very limited uses
Henkypenky
Henkypenkyβ€’16mo ago
well you are right very niche xd You can configure Server Certificates and other listener options by using Network Shell (netsh.exe). See Network Shell (Netsh) for more details. The executable began shipping with Windows Server 2008 and Windows Vista. read the documentation
Angius
Angiusβ€’16mo ago
https://stackoverflow.com/questions/11403333/httplistener-with-https-support here's something on making your own certs Do mind, that they're per-domain and that includes the port You can't make a catch-all certificate
maria 🌟
maria πŸŒŸβ€’16mo ago
Y just want to make my http listener secure :c i got error makecert.exe doenst exist
Angius
Angiusβ€’16mo ago
Stack Overflow
Httplistener with HTTPS support
There seems to be a lot of confusing, sometimes conflicting, information with regards to making a .NET HTTPListener HTTPS capable. My understanding is as follows: One's C# code needs an https pref...
Angius
Angiusβ€’16mo ago
You can use openssl instead Or perhaps even PuTTy key generator
maria 🌟
maria πŸŒŸβ€’16mo ago
sdasdsa
Angius
Angiusβ€’16mo ago
If you have Git installed (which you should) OpenSSL comes with it
maria 🌟
maria πŸŒŸβ€’16mo ago
i dont
Angius
Angiusβ€’16mo ago
You can easily correct this mistake
maria 🌟
maria πŸŒŸβ€’16mo ago
why is so dificult 😫 and on node express its just all auto
Angius
Angiusβ€’16mo ago
Well it would be automatic if you used ASP But you decided to reinvent the wheel and rawdog it from bare HttpListener
maria 🌟
maria πŸŒŸβ€’16mo ago
on ASP.NET Core httplistener is betteR?
Angius
Angiusβ€’16mo ago
There's no HttpListener It's very low-level ASP is a more high-level framework
maria 🌟
maria πŸŒŸβ€’16mo ago
and how i do a https listener on thath
Angius
Angiusβ€’16mo ago
You don't Why would you?
maria 🌟
maria πŸŒŸβ€’16mo ago
because i want to do a server?
Angius
Angiusβ€’16mo ago
Well, ASP does just that You're too stuck on that HttpListener Forget it exists Forget you ever learned about it If you want an API, use a WebAPI project. Then you'll be able to just declare a controller and an actiona nd it will just work If you want something closer to Express, use a Minimal API project
maria 🌟
maria πŸŒŸβ€’16mo ago
i want it local and on c#
Angius
Angiusβ€’16mo ago
And it'll be the same. Define a route, return a response, works So? Everything I mentioned is C# Everything I mentioned can run locally
maria 🌟
maria πŸŒŸβ€’16mo ago
umm
maria 🌟
maria πŸŒŸβ€’16mo ago
umm
Henkypenky
Henkypenkyβ€’16mo ago
first one
maria 🌟
maria πŸŒŸβ€’16mo ago
ye i know and this i coould send the files and run it on other computer?
Angius
Angiusβ€’16mo ago
What do you mean? Yes, you can publish it to an executable and run it elsewhere Yes, you can zip up the project files and compile and run it elsewhere
maria 🌟
maria πŸŒŸβ€’16mo ago
ummm
maria 🌟
maria πŸŒŸβ€’16mo ago
umm
Angius
Angiusβ€’16mo ago
The first one, yeah
maria 🌟
maria πŸŒŸβ€’16mo ago
umm
Angius
Angiusβ€’16mo ago
Idk what any of that says but looks good enough "something something https" is checked, so that seems fine
maria 🌟
maria πŸŒŸβ€’16mo ago
ummm
Angius
Angiusβ€’16mo ago
There you go
maria 🌟
maria πŸŒŸβ€’16mo ago
i have absolutly no idea of how this works
maria 🌟
maria πŸŒŸβ€’16mo ago
umm
Angius
Angiusβ€’16mo ago
No clue what it says Agree to whatever it is You can check "no volver la pregnant" if you deem it necessary
Henkypenky
Henkypenkyβ€’16mo ago
thats the self signed certificate
maria 🌟
maria πŸŒŸβ€’16mo ago
?
Henkypenky
Henkypenkyβ€’16mo ago
click yes
EL PRO V3.1
EL PRO V3.1β€’16mo ago
oye como se llama ese editor
Angius
Angiusβ€’16mo ago
There you go, it works now
maria 🌟
maria πŸŒŸβ€’16mo ago
visual studio?
EL PRO V3.1
EL PRO V3.1β€’16mo ago
pense que era otro
Henkypenky
Henkypenkyβ€’16mo ago
trust ASP.NET Core SSL Certificate
maria 🌟
maria πŸŒŸβ€’16mo ago
but i just wanted like express watch on x port only and handle request and run some code befor no this strange manager page or this is just auto gernerated
Jimmacle
Jimmacleβ€’16mo ago
look at minimal apis maybe?
maria 🌟
maria πŸŒŸβ€’16mo ago
by the projedxt
Angius
Angiusβ€’16mo ago
It's not a strange manager page, it shows you what endpoints you have in your app You can remove it if you want
Matt
Mattβ€’16mo ago
(and that strange manager page only shows if you're compiling for debug, by default)
Angius
Angiusβ€’16mo ago
Just delete anything with Swagger in your Program.cs
Jimmacle
Jimmacleβ€’16mo ago
i think he can get rid of the endpoint explorer services as well in that case
Matt
Mattβ€’16mo ago
in VS, you will also want to edit launchSettings.json to disable launching the browser (assuming you remove Swagger)
maria 🌟
maria πŸŒŸβ€’16mo ago
ammm
Jimmacle
Jimmacleβ€’16mo ago
it's self explanatory
Angius
Angiusβ€’16mo ago
All that matters is the Controllers folder tbh Make a new controller class there Add action methods Boom
Jimmacle
Jimmacleβ€’16mo ago
Tutorial: Create a minimal API with ASP.NET Core
Learn how to build a minimal API with ASP.NET Core.
maria 🌟
maria πŸŒŸβ€’16mo ago
this is perfect
maria 🌟
maria πŸŒŸβ€’16mo ago
but im seeing thath aspnet core web api is for big apis like realy big and complex ap
Jimmacle
Jimmacleβ€’16mo ago
it's for any web api like that example, that's about the smallest "api" you can make
Angius
Angiusβ€’16mo ago
Well, yeah, APIs are generally large and complex, so the WebAPI has proper ways to handle that complexity The minimal API is, well, minimal
Matt
Mattβ€’16mo ago
the DI framework is amazing ^
maria 🌟
maria πŸŒŸβ€’16mo ago
Di framworkΒΏ
Jimmacle
Jimmacleβ€’16mo ago
Dependency injection - .NET
Learn how to use dependency injection within your .NET apps. Discover how to registration services, define service lifetimes, and express dependencies in C#.
Angius
Angiusβ€’16mo ago
Dependency injection
Jimmacle
Jimmacleβ€’16mo ago
googleℒ️
maria 🌟
maria πŸŒŸβ€’16mo ago
Swagger is like a very big debugger for apis right?
Jimmacle
Jimmacleβ€’16mo ago
no it's a documentation tool
Angius
Angiusβ€’16mo ago
And lets you make requests to those endpoints without the need for a client like Postman
maria 🌟
maria πŸŒŸβ€’16mo ago
yea and when exceptions ocuress has like a full stack of erros
Angius
Angiusβ€’16mo ago
That's always a thing When an exception happens in C#, you get the stack trace
maria 🌟
maria πŸŒŸβ€’16mo ago
yea but it swows on the web
Jimmacle
Jimmacleβ€’16mo ago
that's just asp.net core in development mode you get detailed error pages if an exception is thrown
maria 🌟
maria πŸŒŸβ€’16mo ago
how i configure the port
Matt
Mattβ€’16mo ago
launchSettings.json in VS :p
maria 🌟
maria πŸŒŸβ€’16mo ago
oh
Angius
Angiusβ€’16mo ago
Well, the settings files in general VS or not
maria 🌟
maria πŸŒŸβ€’16mo ago
i got conection refuse on https://localhost:9090/ works but on https://192.168.1.2:9090/ not
Henkypenky
Henkypenkyβ€’16mo ago
localhost is 127.0.0.1 not your private ip
maria 🌟
maria πŸŒŸβ€’16mo ago
oh i forgot it :c still not working
Henkypenky
Henkypenkyβ€’16mo ago
what do you want to do
maria 🌟
maria πŸŒŸβ€’16mo ago
acess to api from my phone to computer
Henkypenky
Henkypenkyβ€’16mo ago
change localhost to 0.0.0.0
maria 🌟
maria πŸŒŸβ€’16mo ago
curl: (60) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The destination principal name is incorrect.
Henkypenky
Henkypenkyβ€’16mo ago
google i need to go now
Accord
Accordβ€’16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
maria 🌟
maria πŸŒŸβ€’16mo ago
stil having ssl errors
Accord
Accordβ€’16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.