Last change
on this file since 1532 was
1530,
checked in by gkronber, 15 years ago
|
Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576
|
File size:
1.7 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.ServiceModel.Channels;
|
---|
6 | using System.ServiceModel;
|
---|
7 | using System.Security.Cryptography.X509Certificates;
|
---|
8 | using System.Net;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Hive.Contracts {
|
---|
11 | public static class WcfSettings {
|
---|
12 |
|
---|
13 | public static Binding GetBinding() {
|
---|
14 | NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message);
|
---|
15 | return binding;
|
---|
16 | }
|
---|
17 |
|
---|
18 | public static string GetActiveIP() {
|
---|
19 | return System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections()[0].LocalEndPoint.Address.ToString();
|
---|
20 | }
|
---|
21 |
|
---|
22 | public static int GetDefaultPort() {
|
---|
23 | return 9000;
|
---|
24 | }
|
---|
25 | }
|
---|
26 |
|
---|
27 | // WARNUNG: Dieser Code wird nur für Testzertifikate benötigt, wie sie beispielsweise von makecert erstellt werden.
|
---|
28 | // Sie sollten diesen Code nicht in einer Produktionsumgebung verwenden.
|
---|
29 | public class PermissiveCertificatePolicy {
|
---|
30 | string subjectName;
|
---|
31 | static PermissiveCertificatePolicy currentPolicy;
|
---|
32 | PermissiveCertificatePolicy(string subjectName) {
|
---|
33 | this.subjectName = subjectName;
|
---|
34 | ServicePointManager.ServerCertificateValidationCallback +=
|
---|
35 | new System.Net.Security.RemoteCertificateValidationCallback(RemoteCertValidate);
|
---|
36 | }
|
---|
37 |
|
---|
38 | public static void Enact(string subjectName) {
|
---|
39 | currentPolicy = new PermissiveCertificatePolicy(subjectName);
|
---|
40 | }
|
---|
41 |
|
---|
42 | bool RemoteCertValidate(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error) {
|
---|
43 | if (cert.Subject == subjectName) {
|
---|
44 | return true;
|
---|
45 | }
|
---|
46 |
|
---|
47 | return false;
|
---|
48 | }
|
---|
49 | }
|
---|
50 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.