C
C#β€’2y ago
maria 🌟

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

98 Replies
maria 🌟
maria πŸŒŸβ€’2y ago
halp
Angius
Angiusβ€’2y ago
Well you're only listening on http:// so Also, any errors?
maria 🌟
maria πŸŒŸβ€’2y ago
I WANT HTTPS not http
Angius
Angiusβ€’2y ago
Why do you listen on HTTP twice, then?
maria 🌟
maria πŸŒŸβ€’2y ago
port compatibilty
Henkypenky
Henkypenkyβ€’2y ago
you need a certificate for https
Angius
Angiusβ€’2y ago
HttpListener Class (System.Net)
Provides a simple, programmatically controlled HTTP protocol listener. This class cannot be inherited.
Angius
Angiusβ€’2y 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 πŸŒŸβ€’2y ago
aspΒΏ?
Angius
Angiusβ€’2y ago
Yes, the web framework for C# ASP.NET Core
maria 🌟
maria πŸŒŸβ€’2y ago
And how i do it
Henkypenky
Henkypenkyβ€’2y 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β€’2y ago
I mean, HttpListener isn't outdated, it just has some very limited uses
Henkypenky
Henkypenkyβ€’2y 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β€’2y 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 πŸŒŸβ€’2y ago
Y just want to make my http listener secure :c i got error makecert.exe doenst exist
Angius
Angiusβ€’2y 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β€’2y ago
You can use openssl instead Or perhaps even PuTTy key generator
maria 🌟
maria πŸŒŸβ€’2y ago
sdasdsa
Angius
Angiusβ€’2y ago
If you have Git installed (which you should) OpenSSL comes with it
maria 🌟
maria πŸŒŸβ€’2y ago
i dont
Angius
Angiusβ€’2y ago
You can easily correct this mistake
maria 🌟
maria πŸŒŸβ€’2y ago
why is so dificult 😫 and on node express its just all auto
Angius
Angiusβ€’2y 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 πŸŒŸβ€’2y ago
on ASP.NET Core httplistener is betteR?
Angius
Angiusβ€’2y ago
There's no HttpListener It's very low-level ASP is a more high-level framework
maria 🌟
maria πŸŒŸβ€’2y ago
and how i do a https listener on thath
Angius
Angiusβ€’2y ago
You don't Why would you?
maria 🌟
maria πŸŒŸβ€’2y ago
because i want to do a server?
Angius
Angiusβ€’2y 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 πŸŒŸβ€’2y ago
i want it local and on c#
Angius
Angiusβ€’2y 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 πŸŒŸβ€’2y ago
umm
maria 🌟
maria πŸŒŸβ€’2y ago
umm
Henkypenky
Henkypenkyβ€’2y ago
first one
maria 🌟
maria πŸŒŸβ€’2y ago
ye i know and this i coould send the files and run it on other computer?
Angius
Angiusβ€’2y 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 πŸŒŸβ€’2y ago
ummm
maria 🌟
maria πŸŒŸβ€’2y ago
umm
Angius
Angiusβ€’2y ago
The first one, yeah
maria 🌟
maria πŸŒŸβ€’2y ago
umm
Angius
Angiusβ€’2y ago
Idk what any of that says but looks good enough "something something https" is checked, so that seems fine
maria 🌟
maria πŸŒŸβ€’2y ago
ummm
Angius
Angiusβ€’2y ago
There you go
maria 🌟
maria πŸŒŸβ€’2y ago
i have absolutly no idea of how this works
maria 🌟
maria πŸŒŸβ€’2y ago
umm
Angius
Angiusβ€’2y 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β€’2y ago
thats the self signed certificate
maria 🌟
maria πŸŒŸβ€’2y ago
?
Henkypenky
Henkypenkyβ€’2y ago
click yes
EL PRO V3.1
EL PRO V3.1β€’2y ago
oye como se llama ese editor
Angius
Angiusβ€’2y ago
There you go, it works now
maria 🌟
maria πŸŒŸβ€’2y ago
visual studio?
EL PRO V3.1
EL PRO V3.1β€’2y ago
pense que era otro
Henkypenky
Henkypenkyβ€’2y ago
trust ASP.NET Core SSL Certificate
maria 🌟
maria πŸŒŸβ€’2y 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β€’2y ago
look at minimal apis maybe?
maria 🌟
maria πŸŒŸβ€’2y ago
by the projedxt
Angius
Angiusβ€’2y 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β€’2y ago
(and that strange manager page only shows if you're compiling for debug, by default)
Angius
Angiusβ€’2y ago
Just delete anything with Swagger in your Program.cs
Jimmacle
Jimmacleβ€’2y ago
i think he can get rid of the endpoint explorer services as well in that case
Matt
Mattβ€’2y ago
in VS, you will also want to edit launchSettings.json to disable launching the browser (assuming you remove Swagger)
maria 🌟
maria πŸŒŸβ€’2y ago
ammm
Jimmacle
Jimmacleβ€’2y ago
it's self explanatory
Angius
Angiusβ€’2y ago
All that matters is the Controllers folder tbh Make a new controller class there Add action methods Boom
Jimmacle
Jimmacleβ€’2y ago
Tutorial: Create a minimal API with ASP.NET Core
Learn how to build a minimal API with ASP.NET Core.
maria 🌟
maria πŸŒŸβ€’2y ago
this is perfect
maria 🌟
maria πŸŒŸβ€’2y ago
but im seeing thath aspnet core web api is for big apis like realy big and complex ap
Jimmacle
Jimmacleβ€’2y ago
it's for any web api like that example, that's about the smallest "api" you can make
Angius
Angiusβ€’2y 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β€’2y ago
the DI framework is amazing ^
maria 🌟
maria πŸŒŸβ€’2y ago
Di framworkΒΏ
Jimmacle
Jimmacleβ€’2y 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β€’2y ago
Dependency injection
Jimmacle
Jimmacleβ€’2y ago
googleℒ️
maria 🌟
maria πŸŒŸβ€’2y ago
Swagger is like a very big debugger for apis right?
Jimmacle
Jimmacleβ€’2y ago
no it's a documentation tool
Angius
Angiusβ€’2y ago
And lets you make requests to those endpoints without the need for a client like Postman
maria 🌟
maria πŸŒŸβ€’2y ago
yea and when exceptions ocuress has like a full stack of erros
Angius
Angiusβ€’2y ago
That's always a thing When an exception happens in C#, you get the stack trace
maria 🌟
maria πŸŒŸβ€’2y ago
yea but it swows on the web
Jimmacle
Jimmacleβ€’2y ago
that's just asp.net core in development mode you get detailed error pages if an exception is thrown
maria 🌟
maria πŸŒŸβ€’2y ago
how i configure the port
Matt
Mattβ€’2y ago
launchSettings.json in VS :p
maria 🌟
maria πŸŒŸβ€’2y ago
oh
Angius
Angiusβ€’2y ago
Well, the settings files in general VS or not
maria 🌟
maria πŸŒŸβ€’2y ago
i got conection refuse on https://localhost:9090/ works but on https://192.168.1.2:9090/ not
Henkypenky
Henkypenkyβ€’2y ago
localhost is 127.0.0.1 not your private ip
maria 🌟
maria πŸŒŸβ€’2y ago
oh i forgot it :c still not working
Henkypenky
Henkypenkyβ€’2y ago
what do you want to do
maria 🌟
maria πŸŒŸβ€’2y ago
acess to api from my phone to computer
Henkypenky
Henkypenkyβ€’2y ago
change localhost to 0.0.0.0
maria 🌟
maria πŸŒŸβ€’2y ago
curl: (60) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The destination principal name is incorrect.
Henkypenky
Henkypenkyβ€’2y ago
google i need to go now
Accord
Accordβ€’2y 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 πŸŒŸβ€’2y ago
stil having ssl errors
Accord
Accordβ€’2y 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.
Want results from more Discord servers?
Add your server