I wanted to ask you this yesterday... does your code work ok without all of the cert stuff? I have not read your code fragment but wanted to know if you have a non ssl/tls working example. If you do, then we sort of know where not to look... if you do not have a non ssl/tls working example, can you start over... reprovision unsecurely, etc... and try to get that to work first?
I do recall the sdk redirection sample worked ok for me. You should be able to get it to work okwith a non securely provisioned machine... can you try it and let us know if that works? I think knowing if that works or not would be a good thing.
Did you configure AMT with TLS server authentication or TLS mutual authentication? Can you connect to the AMT device through webUI or AMT commander? What is the status code when the connection fails through your application? Please make sure the certificates are setup correctly. Try the webUI first and if that works we can debug what is happening with the IDE-R application.