blah blah blah is here! blah blah » Close

up2down
link

Can it be done? I've got a small .NET app that works on my workstation as well as my development server...but then doesn't work correctly in the Rackspace Cloud. The old version of the site worked fine...so it must be something in the new lines I've added...Those lines involve telling .NET to ignore SSL errors in the request I'm about to send out...load a client cert in memory...and then send a remote web service call. But I don't know exactly where the error is happening, because I'm not actually getting an error message. My program just isn't proceeding past greying out the submit button...

update

The cloud uses medium trust right? I just set the web.config for medium trust on my workstation and my program crashes. It doesn't hang like the version I have on the cloud, but it crashes. It appears to puke at the point where I ask it to ignore SSL errors.

ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);


Update 2

So after poking around for a while....OK really it was after I started javascript debugging in my web browser, I finally came up with an error.

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

Well, that's better. So the server is throwing a 500 error while processing my AJAX request. That gets me closer! And then I learned about the event AsyncPostBackError.

ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message;


Yay! I finally get a REAL error to dump.

The specified network password is not correct.

Huh? Um OK...Not sure what that means. So instead, I put a new update panel at the bottom of my page with a label in it. I put the entire code block in a try statement and made a catch that makes the panel visible and prints full details in the panel. Much better error message.

The specified network password is not correct.

at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password) at NetParkProxy.AddReservation(String certFile, DateTime CheckIn, DateTime CheckOut, String FirstName, String LastName, String EMail, String Address, String City, String State, String ZIP, String Phone) in \\fs1-n02\stor2wc1dfw1\401175\414236\www.----------.com\web\content\App_Code\NetParkProxy.cs:line 24 at _Default.btnConfirm_Click(Object sender, EventArgs e) in \\fs1-n02\stor2wc1dfw1\401175\414236\www.-----------.com\web\content\Default.aspx.cs:line 183
mscorlib

MUCH better. So the line in question is:

X509Certificate2 cert = new X509Certificate2(certFile, string.Empty);


So here's the new question. Why does this line work fine on my workstation and local dev server, but not when uploaded to the rackspace cloud?? I checked the file permissions on the cert and they are set for 755.

salman
510

@codo I moved your comment and edited your question, try and keep comments for conversations w/o code.

MadHatter
2309

that bit of code in your question is for a client to manually validate the server certificate and return whether it's valid or not, not for the server to do anything with (or ignore) an ssl cert.

Codo
84

@MadHatter: Yeah, that's something I needed to do because the webservice I'm using seems to have either an oddball CA or they are self-signed certs. They said I either had to ignore SSL errors during processing or I had to install their CA cert on my box. Obviously installing the CA cert isn't going to work...Hence this code. Turns out however that this is not where it was puking though...

last answered 2 years ago

2 answers

up0down
link

I'm not sure you will be able to remote debug the application (just doubt it, ask support for that one).

Your best bet might be some old school debug techniques, maybe write to file to figure out where exactly the issue is starting from.

I would also read up on how cloud hosting handles SSL, as its not the usual case.

For instance, I had some issues with getting visitor IP information (I had to change my code to use another server variable key: see rackspace cloud ip address).

Feedback