Index: /branches/OaaS/HeuristicLab 3.3 Hive.Slave.sln
===================================================================
--- /branches/OaaS/HeuristicLab 3.3 Hive.Slave.sln	(revision 8250)
+++ /branches/OaaS/HeuristicLab 3.3 Hive.Slave.sln	(revision 8251)
@@ -21,4 +21,6 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave.AzureClient-3.3", "HeuristicLab.Clients.Hive.Slave.AzureClient\3.3\HeuristicLab.Clients.Hive.Slave.AzureClient-3.3.csproj", "{D0DDC7C9-9215-4325-AA2F-0C4ABF809321}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive-3.3", "HeuristicLab.Clients.Hive\3.3\HeuristicLab.Clients.Hive-3.3.csproj", "{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}"
 EndProject
 Global
@@ -144,4 +146,16 @@
 		{D0DDC7C9-9215-4325-AA2F-0C4ABF809321}.Release|x64.ActiveCfg = Release|Any CPU
 		{D0DDC7C9-9215-4325-AA2F-0C4ABF809321}.Release|x86.ActiveCfg = Release|Any CPU
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Debug|x64.ActiveCfg = Debug|x64
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Debug|x64.Build.0 = Debug|x64
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Debug|x86.ActiveCfg = Debug|x86
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Debug|x86.Build.0 = Debug|x86
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Release|x64.ActiveCfg = Release|x64
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Release|x64.Build.0 = Release|x64
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Release|x86.ActiveCfg = Release|x86
+		{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
Index: /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceConfiguration.Cloud.cscfg
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceConfiguration.Cloud.cscfg	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceConfiguration.Cloud.cscfg	(revision 8251)
@@ -5,4 +5,6 @@
     <ConfigurationSettings>
       <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
+      <Setting name="HiveServerAddress" value="" />
+      <Setting name="HiveServerCertifcateEncodedValue" value="" />
     </ConfigurationSettings>
   </Role>
Index: /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceConfiguration.Local.cscfg
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceConfiguration.Local.cscfg	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceConfiguration.Local.cscfg	(revision 8251)
@@ -5,4 +5,6 @@
     <ConfigurationSettings>
       <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
+      <Setting name="HiveServerAddress" value="" />
+      <Setting name="HiveServerCertifcateEncodedValue" value="" />
     </ConfigurationSettings>
   </Role>
Index: /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceDefinition.build.csdef
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceDefinition.build.csdef	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceDefinition.build.csdef	(revision 8251)
@@ -14,4 +14,8 @@
       <Import moduleName="Diagnostics" />
     </Imports>
+    <ConfigurationSettings>
+      <Setting name="HiveServerAddress" />
+      <Setting name="HiveServerCertifcateEncodedValue" />
+    </ConfigurationSettings>
   </WorkerRole>
 </ServiceDefinition>
Index: /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceDefinition.csdef
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceDefinition.csdef	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive.Slave.Azure/ServiceDefinition.csdef	(revision 8251)
@@ -5,4 +5,8 @@
       <Import moduleName="Diagnostics" />
     </Imports>
+    <ConfigurationSettings>
+      <Setting name="HiveServerAddress" />
+      <Setting name="HiveServerCertifcateEncodedValue" />
+    </ConfigurationSettings>
   </WorkerRole>
 </ServiceDefinition>
Index: /branches/OaaS/HeuristicLab.Clients.Hive.Slave.AzureClient/3.3/WorkerRole.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive.Slave.AzureClient/3.3/WorkerRole.cs	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive.Slave.AzureClient/3.3/WorkerRole.cs	(revision 8251)
@@ -32,6 +32,18 @@
     private Thread coreThread;
 
+    private const string HiveServerAddressSetting = "HiveServerAddress";
+    private const string HiveServerCertificateSetting = "HiveServerCertifcateEncodedValue";
+
     public override void Run() {
       core = new Core(false);
+
+      string hiveServerAddress = RoleEnvironment.GetConfigurationSettingValue(HiveServerAddressSetting);
+      string hiveServerCertificate = RoleEnvironment.GetConfigurationSettingValue(HiveServerCertificateSetting);
+
+      // values are empty, settings from app.config are used
+      if (!string.IsNullOrEmpty(hiveServerAddress) && !string.IsNullOrEmpty(hiveServerCertificate)) {
+        core.SetNewHiveServer(hiveServerAddress, hiveServerCertificate);
+      }
+
       coreThread = new Thread(core.Start);
       coreThread.Start();
@@ -59,4 +71,6 @@
       }
 
+      RoleEnvironment.Changed += RoleEnvironmentChanged;
+
       return base.OnStart();
     }
@@ -66,4 +80,7 @@
       base.OnStop();
     }
+
+    private void RoleEnvironmentChanged(object sender, RoleEnvironmentChangedEventArgs e) {
+    }
   }
 }
Index: /branches/OaaS/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs	(revision 8251)
@@ -500,4 +500,17 @@
     }
     #endregion
+
+    public void SetNewHiveServer(string remote, string identity) {
+      SlaveClientCom.Instance.LogMessage("Set new hive server address and identity");
+      HiveServiceLocator.Instance.RemoteAddress = remote;
+      HiveServiceLocator.Instance.IdentityCertificate = identity;
+    }
+
+    public void ChangeHiveServerAndRestart(string remote, string identity) {
+      SlaveClientCom.Instance.LogMessage("Change hive server");
+      ShutdownCore();
+      SetNewHiveServer(remote, identity);
+      Start();
+    }
   }
 }
Index: /branches/OaaS/HeuristicLab.Clients.Hive/3.3/HiveServiceLocator.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive/3.3/HiveServiceLocator.cs	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive/3.3/HiveServiceLocator.cs	(revision 8251)
@@ -21,4 +21,6 @@
 
 using System;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
 using HeuristicLab.Clients.Common;
 
@@ -47,10 +49,35 @@
     }
 
+    private string remoteAddress;
+    public string RemoteAddress {
+      get { return remoteAddress; }
+      set { remoteAddress = value; }
+    }
+
+    private string identityCertificate;
+    public string IdentityCertificate {
+      get { return identityCertificate; }
+      set { identityCertificate = value; }
+    }
+
     private HiveServiceClient NewServiceClient() {
       HiveServiceClient cl;
       if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
         cl = ClientFactory.CreateClient<HiveServiceClient, IHiveService>();
-      else
+      else {
         cl = ClientFactory.CreateClient<HiveServiceClient, IHiveService>(null, null, username, password);
+      }
+
+      if (!string.IsNullOrEmpty(remoteAddress) && !string.IsNullOrEmpty(identityCertificate)) {
+
+        X509Certificate2Collection supportingCertificates = new X509Certificate2Collection();
+        supportingCertificates.Import(Convert.FromBase64String(identityCertificate));
+
+        X509Certificate2 primaryCertificate = supportingCertificates[0];
+        supportingCertificates.RemoveAt(0);
+        EndpointIdentity ei = EndpointIdentity.CreateX509CertificateIdentity(primaryCertificate, supportingCertificates);
+
+        cl.Endpoint.Address = new EndpointAddress(new Uri(remoteAddress), ei);
+      }
 
       return cl;
Index: /branches/OaaS/HeuristicLab.Clients.Hive/3.3/IHiveServiceLocator.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Clients.Hive/3.3/IHiveServiceLocator.cs	(revision 8250)
+++ /branches/OaaS/HeuristicLab.Clients.Hive/3.3/IHiveServiceLocator.cs	(revision 8251)
@@ -26,4 +26,6 @@
     string Username { get; set; }
     string Password { get; set; }
+    string RemoteAddress { get; set; }
+    string IdentityCertificate { get; set; }
     void CallHiveService(Action<IHiveService> call);
     T CallHiveService<T>(Func<IHiveService, T> call);
