| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using System.Net.Security; |
| | 4 | | using System.Security.Cryptography.X509Certificates; |
| | 5 | |
|
| | 6 | | namespace Ice.SSL; |
| | 7 | |
|
| | 8 | | internal class AcceptorI : Ice.Internal.Acceptor |
| | 9 | | { |
| 1 | 10 | | public void close() => _delegate.close(); |
| | 11 | |
|
| | 12 | | public Ice.Internal.EndpointI listen() |
| | 13 | | { |
| 1 | 14 | | _endpoint = _endpoint.endpoint(_delegate.listen()); |
| 1 | 15 | | return _endpoint; |
| | 16 | | } |
| | 17 | |
|
| | 18 | | public bool startAccept(Ice.Internal.AsyncCallback callback, object state) => |
| 1 | 19 | | _delegate.startAccept(callback, state); |
| | 20 | |
|
| 1 | 21 | | public void finishAccept() => _delegate.finishAccept(); |
| | 22 | |
|
| | 23 | | public Ice.Internal.Transceiver accept() => |
| 1 | 24 | | new TransceiverI( |
| 1 | 25 | | _instance, |
| 1 | 26 | | _delegate.accept(), |
| 1 | 27 | | _adapterName, |
| 1 | 28 | | incoming: true, |
| 1 | 29 | | serverAuthenticationOptions: _serverAuthenticationOptions); |
| | 30 | |
|
| 0 | 31 | | public string protocol() => _delegate.protocol(); |
| | 32 | |
|
| 1 | 33 | | public override string ToString() => _delegate.ToString(); |
| | 34 | |
|
| 1 | 35 | | public string toDetailedString() => _delegate.toDetailedString(); |
| | 36 | |
|
| 1 | 37 | | internal AcceptorI( |
| 1 | 38 | | EndpointI endpoint, |
| 1 | 39 | | Instance instance, |
| 1 | 40 | | Ice.Internal.Acceptor del, |
| 1 | 41 | | string adapterName, |
| 1 | 42 | | SslServerAuthenticationOptions authenticationOptions) |
| | 43 | | { |
| 1 | 44 | | _endpoint = endpoint; |
| 1 | 45 | | _delegate = del; |
| 1 | 46 | | _instance = instance; |
| 1 | 47 | | _adapterName = adapterName; |
| 1 | 48 | | _serverAuthenticationOptions = authenticationOptions; |
| | 49 | |
|
| | 50 | | // .NET requires that a certificate be supplied. |
| 1 | 51 | | X509Certificate2Collection certs = instance.certs(); |
| 1 | 52 | | if ((certs is null || certs.Count == 0) && _serverAuthenticationOptions is null) |
| | 53 | | { |
| 0 | 54 | | throw new Ice.SecurityException("IceSSL: certificate required for server endpoint"); |
| | 55 | | } |
| 1 | 56 | | } |
| | 57 | |
|
| | 58 | | private readonly string _adapterName; |
| | 59 | | private readonly Ice.Internal.Acceptor _delegate; |
| | 60 | | private EndpointI _endpoint; |
| | 61 | | private readonly Instance _instance; |
| | 62 | | private readonly SslServerAuthenticationOptions _serverAuthenticationOptions; |
| | 63 | | } |