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

Error Invalid username/password with password has "@" character #115

Open
tegiac97 opened this issue Sep 18, 2021 · 4 comments
Open

Error Invalid username/password with password has "@" character #115

tegiac97 opened this issue Sep 18, 2021 · 4 comments

Comments

@tegiac97
Copy link

tegiac97 commented Sep 18, 2021

Describe the bug
If password has "@" character like abc@123@. Exception occurred in ConnectAsync. Invalid Username/Password
I checked in NetworkCredential, the correct password is abc@123@
Does anyone have any solution? THank you for helping!
This is my src code.

            var cancellationTokenSource = new CancellationTokenSource();
            string rtspUrl = "rtsp://" + rtspinfo.IPAddress + ":" + rtspinfo.Port + "/";
            Console.WriteLine(rtspUrl);
            var serverUri = new Uri(rtspUrl);
            var credentials = new NetworkCredential(rtspinfo.Username, rtspinfo.Password);
            rtspinfo.Username = "admin";
            rtspinfo.Password = "abc@123@";
            var connectionParameters = new ConnectionParameters(serverUri, credentials);
            connectionParameters.RtpTransport = RtpTransportProtocol.TCP;
            using var rtspClient = new RtspClient(connectionParameters);
            try
            {
                await rtspClient.ConnectAsync(cancellationTokenSource.Token);
                Console.WriteLine("Inside rtsp checker");
                result.Status = true;
                result.Exception = "";
                return result;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
                result.Exception = ex.Message;
                result.Status = false;
                return result;
            }```
@tegiac97 tegiac97 changed the title Error Invalid username/password with password has "@ Error Invalid username/password with password has "@" character Sep 18, 2021
@kitsune4295
Copy link

The "@" symbol has special meaning in the RTSP protocol. While it is not impossible to use it in a password on an IP camera, a lot of RSTP clients have issues with passwords containing "@". To be specific, the "@" symbol is used to signal to the RSTP server the end of the username/password string, and the beginning of the RSTP URI.

@tegiac97
Copy link
Author

IP camera password can use "@" symbol. I tried it on UNV, hikvision cameras. I can run stream with password with "@" character using vlc or ffmpeg.

@kitsune4295
Copy link

Depends on the implementation of the RTSP client. I am fairly new this this particular library, But for my day job I work for a security integrator and have personally designed and deployed the some of the largest IP CCTV systems in the country... The most common way I have seen software implement the RTSP protocol is to embed the username and password directly into the URI. This is why I typically tell my clients not to use the @ symbol in a password for an IP camera. Yes, most cameras will let you do this, but it tends to cause a lot of problems when software tries to connect to the camera and pull an RTSP stream, because the @ symbol is used as a delimiter between the username/password, and the rest of the URI for the RTSP connection request.

I'll use an example of a Hanwha camera, that has a username of "admin" and a password of "password1", and an IP address of 192.168.1.100. (Hanwha's default IP)

rtsp://admin:password1@192.168.1.100/profile1/media.smp

If the password has an @ in it, and the RTSP client chooses this connection method, you end up confusing the RTSP server because it thinks the password ends before the @. This is not a bug, rather a limitation of the "Basic Authentication" method in the RTSP protocol. As you noted with VLC, it is possible for some software to work around this, using "Digest Authentication" where the client passes a hash of the username and password to the RTSP server after the initial connection.
Some software like VLC support both authentication methods, but a disgusting amount of software out there, both commercial and open source, only support basic authentication for RTSP.

I'd bet money that this project only supports basic authentication.

Please note, I am just a user like your self, and am in no way affiliated with RtspClientSharp, and am looking at using this project to develop an AI analytic. That said, I am leaning towards using a different library now because this project looks like its abandoned.

@BoosterPhilipp666
Copy link

Maybe you can change the @ to -> %40 which would be the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants