Getting FABRIC_E_SERVER_AUTHENTICATION_FAILED: CertificateNotMatched with Service Fabric FabricClient - azure-service-fabric

The following console application fails with the exception
static void Main(string[] args)
{
X509Credentials cert = new X509Credentials
{
FindType = X509FindType.FindByThumbprint,
FindValue = "10A9BF925F41370FE55A4BDED2EF803505100C35",
ProtectionLevel = ProtectionLevel.EncryptAndSign,
StoreLocation = StoreLocation.CurrentUser,
StoreName = "My",
};
var fabricClient = new FabricClient(cert,
new FabricClientSettings
{
ClientFriendlyName = "S-Innovations VSTS Deployment Client"
}, "pksservicefabric11.westeurope.cloudapp.azure.com:19000");
var a = fabricClient.QueryManager.GetApplicationListAsync().Result;
}
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.Fabric.FabricServerAuthenticationFailedException: FABRIC_E_SERVER_AUTHENTICATION_FAILED: CertificateNotMatched ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071C44
at System.Fabric.Interop.NativeClient.IFabricQueryClient7.EndGetApplicationList2(IFabricAsyncOperationContext context)
at System.Fabric.FabricClient.QueryClient.GetApplicationListAsyncEndWrapper(IFabricAsyncOperationContext context)
at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at DeployServiceFabricApplicationTask.Program.Main(String[] args) in C:\dev\sinnovations\MessageProcessor.ServiceFabric\vsts\DeployServiceFabricApplicationTask\Program.cs:line 32
Press any key to continue . . .

Adding the thumbprint to the RemoteCertThumbprints list solves the problem:
X509Credentials cert = new X509Credentials
{
FindType = X509FindType.FindByThumbprint,
FindValue = "10A9BF925F41370FE55A4BDED2EF803505100C35",
ProtectionLevel = ProtectionLevel.EncryptAndSign,
StoreLocation = StoreLocation.CurrentUser,
StoreName = "My",
};
cert.RemoteCertThumbprints.Add("10A9BF925F41370FE55A4BDED2EF803505100C35");

Related

Sending message to JMS (Weblogic)

When I run the following code it seems that the message was sent to the queue but I can not see anythyng on the queue. There is no error, exception durig executing my code.
I use Weblogic server.
This is my code:
private InitialContext getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
env.put(InitialContext.INITIAL_CONTEXT_FACTORY, contextFactory);
env.put(InitialContext.PROVIDER_URL, providerUrl);
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
return new InitialContext(env);
}
public ConnectionFactory getConnectionFactory(InitialContext context) throws NamingException {
return (ConnectionFactory) context.lookup(ConnectionParameter.JMS_CONNECTION_FACTORY_JNDI);
}
public void send() throws NamingException, JMSException {
InitialContext context = getInitialContext();
Destination destination = (Destination) context.lookup("jms/dpdr/mhcinterface/arnoldQueue");
try (Connection connection = getConnectionFactory(context).createConnection();){
Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session.createProducer(destination);
Message message = session.createTextMessage("work order complete!");
sender.send(message);
session.commit();
session.close();
}
context.close();
System.out.println("-- end --");
}
Any idea what is wrong here please?
It looks like you forgot to call connection.start() before sending your message. You can do it like below:
MessageProducer sender = session.createProducer(destination);
connection.start();
Message message = session.createTextMessage("work order complete!");

Xamarin Android: SOAP Webservice fails (401 Unauthorized) but my credentails are correct

Error in Xamarin.Android
I get the following error:
{System.Net.WebException: The request failed with HTTP status 401:
Unauthorized at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReceiveResponse
(System.Net.WebResponse response,
System.Web.Services.Protocols.SoapClientMessage message,
System.Web.Services.Protocols.SoapExtension[] extensions) [0x00055] in
/Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs:273
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke
(System.String method_name, System.Object[] parameters) [0x000b8] in
/Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs:365
at DSPFood.Droid.SOAP.scan.ShipGetNewBatchCode (System.String
scannerID) [0x00001] in C:\Projects\Projecten\DSP
Food\Solution\DSPFood\DSPFood\DSPFood.Droid\Web
References\SOAP\Reference.cs:389 at (wrapper
remoting-invoke-with-check)
DSPFood.Droid.SOAP.scan:ShipGetNewBatchCode (string) at
DSPFood.Droid.DependencyServices.SoapService+d__13.MoveNext
() [0x00057] in C:\Projects\Projecten\DSP
Food\Solution\DSPFood\DSPFood\DSPFood.Droid\DependencyServices\SoapService.cs:290
}
Working code in Console application
But when I run following code in a console application it works:
static void Main(string[] args)
{
var nc = new NetworkCredential("**", "**");
var soapClient = new SOAP.scan();
soapClient.UseDefaultCredentials = true;
soapClient.Credentials = nc;
var response = soapClient.ProdGetNewBatchCode("");
}
Response: "A000000086"
Xamarin
public string ShipGetNewBatchCode(string macAddress)
{
var retValue = "";
try
{
var nc = new NetworkCredential("**", "**");
var soapClient = new SOAP.scan();
soapClient.UseDefaultCredentials = true;
soapClient.Credentials = nc;
var response = soapClient.ProdGetNewBatchCode("");
}
catch (Exception ex)
{
throw ex;
}
return retValue;
}
Exception: The request failed with HTTP status 401: Unauthorized

JBoss-A-MQ encountered an UnknownHostException in JMS messaging application

I have a sample JMS messaging application as shown in below snippet. When I executing the program (specifically when starting the connection) I get an UnknowHostException.
The reason for the exception is clientid property get's null.
Application:
public class MessagingTestApp {
private static final String MY_JMS_CONNECTION_FACTORY_NAME = "myJmsFactory";
private static final String EXCHANGE_NAME = "topicExchange";
private static final String JNDI_PROPERTIES_FILE_NAME = "jndi.properties";
private static final String COULD_NOT_LOAD_JNDI_PROPERTIES_MESSAGE = "Could not load JNDI properties....";
private static final boolean NON_TRANSACTED = false;
private static final Logger LOG = Logger.getLogger(MessagingTestApp.class);
public MessagingTestApp() {}
public static void main(String[] args) {
MessagingTestApp messagingTestApp = new MessagingTestApp();
messagingTestApp.runTest();
}
private void runTest() {
try {
Properties properties = new Properties();
properties.load(loadPropertiesFile());
Context context = new InitialContext(properties);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup(MY_JMS_CONNECTION_FACTORY_NAME);
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE);
Destination destination = (Destination) context.lookup(EXCHANGE_NAME);
MessageProducer messageProducer = session.createProducer(destination);
MessageConsumer messageConsumer = session.createConsumer(destination);
TextMessage message = session.createTextMessage("Hello JMS!");
messageProducer.send(message);
message = (TextMessage) messageConsumer.receive();
System.out.println(message.getText());
connection.close();
context.close();
} catch (Exception e) {
LOG.error(e);
e.printStackTrace();
}
}
private InputStream loadPropertiesFile() {
Thread currentThread = Thread.currentThread();
ClassLoader contextClassLoader = currentThread.getContextClassLoader();
InputStream propertiesStream = contextClassLoader.getResourceAsStream(JNDI_PROPERTIES_FILE_NAME);
if (propertiesStream != null) {
return propertiesStream;
} else {
System.out.println(COULD_NOT_LOAD_JNDI_PROPERTIES_MESSAGE);
return null;
}
}
}
JNDI properties file:
java.naming.factory.initial = org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory
java.naming.provider.url = src/main/resources/jndi.properties
connectionfactory.myJmsFactory = amqp://admin:admin#clientid/test?
brokerlist = 'tcp://localhost:5672'
destination.topicExchange = amq.topic
Stack-trace:
javax.jms.JMSException: java.net.UnknownHostException: clientid
at org.apache.qpid.amqp_1_0.jms.impl.ConnectionImpl.connect(ConnectionImpl.java:112)
at org.apache.qpid.amqp_1_0.jms.impl.ConnectionImpl.start(ConnectionImpl.java:266)
at com.adc.efg.MessagingTestApp.runTest(MessagingTestApp.java:39)
at com.adc.efg.MessagingTestApp.main(MessagingTestApp.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.apache.qpid.amqp_1_0.client.ConnectionException: java.net.UnknownHostException: clientid
at org.apache.qpid.amqp_1_0.client.Connection.<init>(Connection.java:271)
at org.apache.qpid.amqp_1_0.client.Connection.<init>(Connection.java:135)
at org.apache.qpid.amqp_1_0.jms.impl.ConnectionImpl.connect(ConnectionImpl.java:105)
... 8 more
Caused by: java.net.UnknownHostException: clientid
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at org.apache.qpid.amqp_1_0.client.Connection.<init>(Connection.java:159)
... 10 more
I'm new to both JBoss-AMQ and JMS. Much appreciated if anyone can point me out where did I go wrong.
Problem was in JNDI properties file. It should be like below,
java.naming.factory.initial = org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory
java.naming.provider.url = src/main/resources/jndi.properties
connectionfactory.myJmsFactory = amqp://admin:admin#localhost/test?
brokerlist = 'tcp://localhost:5672'
destination.topicExchange = amq.topic

An unhandled exception of type 'System.StackOverflowException' occurred in PointerTemplateUtility.exe

Exception is popping in below code under:- "DataSet ds = new DataSet();"
public DataSet GetCommandResponse(int ID)
{
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("WEB_GetInOutMsgHandlerResponse");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#ID", SqlDbType.Int).Value = ID;
ds = GenericStatementReturnDataSet(cmd, ds, "Unable to fetch template ID");
return ds;
}
It works fine in Most of the time without exception in sometime it throws an exception

Jboss & EJB3 deploy Error for

I am a newer for EJB3 dev.
When I write a EJB3 mdb and I want to deploy it to my jboss (jboss-4.2.3.GA)
some error info is here:
--- MBeans waiting for other MBeans --- ObjectName: jboss.j2ee:jar=HelloWorldEjb.jar,name=QueneMDB01,service=EJB3 State:
FAILED Reason: org.jboss.deployment.DeploymentException: Required
config property RequiredConfigPropertyM
etaData#12c08c7[name=destination
descriptions=[DescriptionMetaData#1941dc9[language=zh]]] for messag
ingType 'javax.jms.MessageListener' not found in activation config
[ActivationConfigProperty(destina tionType=javax.jms.Queue),
ActivationConfigProperty(acknowledgeMode=Auto-acknowledge)]
ra=jboss.jca: service=RARDeployment,name='jms-ra.rar'
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: jboss.j2ee:jar=HelloWorldEjb.jar,name=QueneMDB01,service=EJB3 State:
FAILED Reason: org.jboss.deployment.DeploymentException: Required
config property RequiredConfigPropertyM
etaData#12c08c7[name=destination
descriptions=[DescriptionMetaData#1941dc9[language=zh]]] for messag
ingType 'javax.jms.MessageListener' not found in activation config
[ActivationConfigProperty(destina tionType=javax.jms.Queue),
ActivationConfigProperty(acknowledgeMode=Auto-acknowledge)]
ra=jboss.jca: service=RARDeployment,name='jms-ra.rar'
and my mdb is :
#MessageDriven(activationConfig = {
#ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
public class QueneMDB01 implements MessageListener
{
public void onMessage(Message msg) {
// TODO Auto-generated method stub
try {
TextMessage textMessage = (TextMessage) msg;
System.out.println("MyQueneMDBBean is called "
+ textMessage.getText() + " ");
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
From your error i'd say you forgot to add the destination name (queue name probably).
FAILED Reason: org.jboss.deployment.DeploymentException: Required config property RequiredConfigPropertyM etaData#12c08c7[name=destination descriptions=[DescriptionMetaData#1941dc9[language=zh]]
Example:
http://www.javaissues.com/2011/06/ejb3-message-driven-bean-hello-world.html
BTW, you've set up your queues/topics in JBoss right?
Hope this helps,
Dave