Bug 380 - Transport security cannot be set for WCF Basic Auth calls
Summary: Transport security cannot be set for WCF Basic Auth calls
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- critical
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-08-24 08:53 UTC by fdibartolo
Modified: 2011-08-30 20:50 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
System.ServiceModel assembly error (315.87 KB, image/png)
2011-08-24 08:53 UTC, fdibartolo
Details
Updated System.ServiceModel.dll w/Transport enabled (295.00 KB, application/octet-stream)
2011-08-24 11:38 UTC, Sebastien Pouliot
Details
final fix for S.SM.dll (295.00 KB, application/octet-stream)
2011-08-29 09:30 UTC, Sebastien Pouliot
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description fdibartolo 2011-08-24 08:53:04 UTC
Created attachment 177 [details]
System.ServiceModel assembly error

Hi, after we upgraded to monotocuh 4.x, I am not able to set transport security over wcf basic authentication calls.
This was working fine over monotouch 3.x, where Geoff Norton have made a fix somehow related to this for us (around May 2010, I was working with Eduardo Scoz at that time).

This is kind of a blocking thing for us, as we cant build any new releases.

I am willing to work with anybody to speed this up, and provide assistance as well (steps, test, etc).

The error is literally stating that 'ServiceModel.BasicHttpSecurity' does not contain a definition for 'Transport' after trying to do the following:

var binding =  new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;


Please refer to the attachment for more info.
Thanks a lot in advance.

Fernando Di Bartolo
Comment 1 Sebastien Pouliot 2011-08-24 09:36:34 UTC
The Transport property is not part of the 2.1 (Silverlight) profile used by MonoTouch. If some changes were made in 3.x they were lost somewhen...

Re-adding the property itself is not complicated - but there's likely other things around it that are required. Can you find the original bug number and/or dates so we can try to track what changes were made (and why/how they got removed) ?

Also a small, self-contained, test case would allow us to test if re-introducing the property works like expected.

Thanks
Comment 2 fdibartolo 2011-08-24 10:14:58 UTC
So, the build that Geoff gave us at that time to try the fix was 3.0.40818.0 (this is the System.ServiceModel.dll).

Lets see if these add some more info (this was kinda the beginning of our journey with wcf basic auth)
https://bugzilla.novell.com/show_bug.cgi?id=605795
https://bugzilla.novell.com/show_bug.cgi?id=594110

The last version of monotouch I got this working was with was 3.2.4.

This is an internal corporate app, which uses this configuration, so not sure which other options we have out there, public, that we can test this against.
Same thing we did with Geoff, and if you don't mind, I could use a partial (non-production) build to test the property added myself (and related functionality), and then we can do regression to make sure it is a good build indeed.

Let me know if you need more info.
Thanks a lot!
Comment 3 Sebastien Pouliot 2011-08-24 10:25:23 UTC
Thanks for the information. I'll read the old bugs / commits and get back to you (likely with updated assemblies to test).
Comment 4 Sebastien Pouliot 2011-08-24 10:54:13 UTC
It looks like the patches from #605795 never made it to 'master', i.e. they were either committed into a mono-2-6 branch (or a private MonoTouch 3.x branch), as such MonoTouch 4.x (based on mono-2-10) never got the same fixes.
Comment 5 fdibartolo 2011-08-24 11:13:36 UTC
I see, glad we get to the bottom!
So, can we test a side partial build, or should I wait for the next prod build?
I do appreciate your time!
Thanks!
Comment 6 Sebastien Pouliot 2011-08-24 11:38:51 UTC
Created attachment 178 [details]
Updated System.ServiceModel.dll w/Transport enabled

note: this was build from 'master' but should work with MonoTouch 4.1 (beta) and likely with 4.0.4+

a) make a backup copy of both
/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.dll
/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.dll.mdb

b) replace the .dll with the attached file, remove the .mdb file

c) rebuild your application, test and report back :-)

d) replace the original .dll[.mdb] files if this does not work
Comment 7 fdibartolo 2011-08-24 11:58:06 UTC
Oh boy, you have no idea how much I appreciate this!

I am now leaving to a team event (free food, cant say no!), so I will give this a try tonight when I get home.
Will get back to you for sure!
Thanks again!
Comment 8 Sebastien Pouliot 2011-08-24 16:47:26 UTC
no, problem :) just change the status back to "New" once you updated the bug.
Comment 9 fdibartolo 2011-08-24 19:06:12 UTC
It did work like a charm, and the bug is gone!
As of now, I will keep this version of the assembly close to me, until a new prod release come out :-).

Sebastien, thank you very very much for bearing with me on this, and taking care of it.

I flagged the bug as New, as you requested (not sure if you meant Fixed!).

Thank you so much again.
Comment 10 Sebastien Pouliot 2011-08-24 19:18:39 UTC
Great news :) 

I'll commit to master (to ensure it does not 'break' again for MT 5.0 ;-) and to the concerned branches before closing it.

Thanks for confirming the fix!
Comment 11 Sebastien Pouliot 2011-08-29 09:30:42 UTC
Created attachment 205 [details]
final fix for S.SM.dll

I had to make a small change to the patch since this was failing one unit test (this could be the reason why the original patch was not committed to master immediately... and forgotten afterward).

I'm pretty sure it won't affect your application but to be certain I've attached the new assembly to the bug report. If anything goes wrong with it then please re-open the bug. Thanks!
Comment 12 Sebastien Pouliot 2011-08-29 09:57:27 UTC
master 2bf478c24afa0e36d0ad0440f23a319db6129d7c
mono-2-10 b7061d3e57776930c4271effbbb412771c2f1a3d

Fix pushed in MonoTouch 'master' and 'monotouch-4.2' branches
Comment 13 fdibartolo 2011-08-30 12:45:25 UTC
Hey will test it and let you know as soon as I can.
What I did test was 4.0.5, but you are saying that the fix went into other branches but that one, since I saw the prop was still missing there.

Hope I can get back to you soon.
Comment 14 fdibartolo 2011-08-30 18:53:45 UTC
Ok, I was able to try the new assembly.
Even though it did compile, I am having an error at runtime, while doing a little bit more of a normal smoke test. Given this error, I have switch back to the previous assembly you have provided, but the error was also there.

Looks like this is when it tries to serialize the webservice response. Below I paste a specific class property that is part of the webservice contract:

        private System.Collections.Generic.KeyValuePair<string, string>[] ValuesField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.Collections.Generic.KeyValuePair<string, string>[] Values
        {
            get
            {
                return this.ValuesField;
            }
            set
            {
                this.ValuesField = value;
            }
        }

Here is the stack trace for more info:

Type not found; name: KeyValuePairOfstringstring, namespace: http://schemas.datacontract.org/2004/07/System.Collections.Generic

 at System.Runtime.Serialization.XmlFormatterDeserializer.GetTypeFromNamePair (System.String name, System.String ns) [0x001a6] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:292 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x00076] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:227 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x0027a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id, Boolean empty) [0x00217] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292 
  at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000ba] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:234 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x0027a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.CollectionTypeMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x00064] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:669 
  at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000ba] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:234 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x0027a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id, Boolean empty) [0x00217] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292 
  at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000ba] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:234 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x0027a] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Xml.XmlReader reader, System.Type declaredType, System.Runtime.Serialization.KnownTypeCollection knownTypes, IDataContractSurrogate surrogate, System.Runtime.Serialization.DataContractResolver resolver, System.Runtime.Serialization.DataContractResolver defaultResolver, System.String name, System.String ns, Boolean verifyObjectName) [0x0007e] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:65 
  at System.Runtime.Serialization.DataContractSerializer.ReadObject (System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) [0x00024] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:333 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObject (System.Xml.XmlDictionaryReader reader) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:74 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter.ReadMessagePart (System.ServiceModel.Description.MessagePartDescription part, System.Xml.XmlDictionaryReader r) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts (System.ServiceModel.Description.MessageDescription md, System.ServiceModel.Channels.Message message) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in <filename unknown>:0
Comment 15 Sebastien Pouliot 2011-08-30 20:50:56 UTC
If it occurs with both the new (and old) assemblies I provided then it's another issue. Please re-open only if you get a difference between the two attachments.

I have opened a new bug report (bug #557) to ensure we can easily read back all of this in the future if required (I learned that it's way too easy to get confused when multiple bugs share the same number).