sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.47k stars 442 forks source link

HowTo: Sipsocery scaip+xml message with Auth #1017

Closed BoasE closed 9 months ago

BoasE commented 1 year ago

I'm sending scaip xml messages. With a server which doesnt have a password everything works fine. Now in the next step one server requires a password autentication.

When I look at this documentation I expect a response which challenges me to create the psaswort with which I would need to reply. But I don't get any response. Do I need to bind somewhere else ? Am I missing? Is my expectation correct that a response should be received for the auth?

Simplified Code:


        using var sipTransport = new SIPTransport();
        sipTransport.SIPTransportRequestReceived += (a,b,c) =>
        {
            Console.WriteLine("Request received");
            return Task.CompletedTask;
        };

        sipTransport.SIPTransportResponseReceived += (a,b,c) =>
        {
            Console.WriteLine("Response received");
            return Task.CompletedTask;
        };

        var uriFrom = new SIPURI(fromUser, localIp, null, SIPSchemesEnum.sip, SIPProtocolsEnum.udp);
        var uriTo =  new SIPURI(toUse, context.ProviderConfiguration.GetString("host"), null, SIPSchemesEnum.sip, SIPProtocolsEnum.udp);

       var sipRequest = SIPRequest.GetRequest(SIPMethodsEnum.MESSAGE, uriTo,
            new SIPToHeader(
                null,
                uriTo,
                null),
            uriFromHeader);

        sipRequest.Header.Contact = new List<SIPContactHeader>()
        {
            SIPContactHeader.GetDefaultSIPContactHeader(SIPSchemesEnum.sip)
        };

        sipRequest.Header.ContentType = "application/scaip+xml";
        sipRequest.Body = body;
        var callResult = await sipTransport.SendRequestAsync(sipRequest);
sipsorcery commented 9 months ago

Waht do you mean by "create the password"? The SIP protocol doesn't deal with how passwords are created. It specifies how the password gets used in creating the digest with goes in the SIP authorisation header.

In your example you can probably simplify things by using one of the SIPUserAgent classes. They include properties to set a username and password.