����λ�ã���ҳ > �����̳� > �̳� > IceRPC֮��������ַ��TLS�İ�ȫ��->���ֵ�RPC

IceRPC֮��������ַ��TLS�İ�ȫ��->���ֵ�RPC

��Դ������������|��ʱ�䣺2024-05-12 11:48:43 |���Ķ���120��|�� ��ǩ�� T ȫ ��ַ S C ���� ���� PC ������ ��ȫ �� |����������

�������� .Net 8.0 �µ���RPC �ܸ��˰�������������IceRPC֮��������ַ��TLS�İ�ȫ��->���ֵ�RPC, ���������������Ѳ�����ã�����ֵij������硣 ��������ַ ServerAddress �˽��������ַ�ĸ�����﷨�� �﷨ ��������ַURI���������﷨: protocol:/

�������� .Net 8.0 �µ���RPC

�ܸ��˰�������������IceRPC֮��������ַ��TLS�İ�ȫ��->���ֵ�RPC, ���������������Ѳ�����ã�����ֵij������硣

��������ַ ServerAddress

�˽��������ַ�ĸ�����﷨��

�﷨

��������ַ URI ���������﷨: protocol://host[:port][?name=value][&name=value...]

  • protocol �� (URI����)��Ŀǰ֧�� ice �� icerpc
  • host DNS ���� �� IP ��ַ
  • port �˿ں�; δָ��ʱ��Ĭ�϶˿�Ϊ 4061 ice �� 4062 icerpc

��������ַ URI ������п�·����û��Ƭ�Ρ��������в�ѯ��������Щ����ͨ�����ض��ڴ���ġ�

��ѯ�������� transport ָ���ײ㴫������ơ������Ӧ�ó���ʹ�õ������䣬�����˴���������Ϊ���ǿ���ʹ�õ�Ψһ���䡣 ��ˣ��ڷ�������ַ��ʡ�Դ��� transport �Ǻܳ����ġ�

C# �У��ṹ�� ServerAddress �Ƿ�������ַ URI �Ľ�������֤�����ڱ���URI��Ϣ�ȡ�

�ͻ�����������

�ͻ������ӵ���Ҫ�����Ƿ������ĵ�ַ�� �����߿ͻ���������ε����������DNS ��������Щ��������ַ���Ǻܳ����ġ�

����:

��������ַ ˵��
icerpc://hello.zeroc.com ʹ�� icerpc Э�����ӵ��˿� 4062 �ϵ� hello.zeroc.com �� δָ���ײ㴫�䡣
icerpc://192.168.100.10:10000?transport=quic ʹ�� QUIC �ϵ� icerpc Э�飬���Ӷ˿� 10000 �ϵ� 192.168.100.10 Ip��ַ
ice://hello.zeroc.com ʹ�� ice Э�����Ӷ˿� 4061 �ϵ� hello.zeroc.com ��ַ

����������

ָ������������ʱ��Ҫ�����ķ�������ַ��

�����ָ����������ַ��Ĭ��ֵΪ icerpc://[::0] ������ζ�ţ�����Ĭ�� icerpc �˿� (4062) �����нӿ��ϵ� icerpc ���ӡ�

����������ʱ����������ַ������������ [::0] ������ͨ���ip��ַ�������ǵ�ǰϵͳ���ض��ӿڵ�ip��ַ��

����˿ں�ָ�� 0������ϵͳ���Զ���������ݷ�Χ�ڵĶ˿ںš���Ϊ������������� tcp �� udp �˿� 0��

������һЩʾ��:

��������ַ ˵��
icerpc://192.168.100.10 ʹ��Ĭ�� icerpc �˿� 4062�������� 192.168.100.10 �����Ľӿ��ϵ� icerpc ���ӡ�
icerpc://[::0]:0 �������нӿ��ϵ� icerpc ���ӣ�����ϵͳ�Զ�ѡ��Ҫʹ�õĶ˿ںš�
ice://0.0.0.0:10000 10000 �˿��� IPv4 ��ַ�����нӿ��ϼ��� ice ���ӡ�

C# �У� ���ڷ�������ַ��ָ���˿� 0 ʱ�� Listen �᷵��һ����������ַ�� ���а��� OS ѡ��Ķ˿ںţ�

using IceRpc;

await using var server = new Server(...,new Uri("icerpc://[::1]:0"));
ServerAddress actualServerAddress = server.Listen();
Console.WriteLine($"server is now listening on {actualServerAddress}"); // shows actual port
// then somehow share this server address with the clients

TLS �İ�ȫ��

�˽����ʹ��TLS��������

TLS - ���书��

Ice �� icerpc Э��Ȱ�ȫҲ���Dz���ȫ,��Ϊʹ�� TLS ����ͨ�ţ��ǵײ㴫������Ρ�

icerpc Э��û������ https "s"�仯,Ҳû�����ڰ�ȫ icerpc ���ӵĶ��ذ�ȫ�˿ڡ� ��������������ַ icerpc://hello.zeroc.com ʱ, ���Կ������������ڼ���Ĭ�ϵ� icerpc �˿ڣ����޷��ж����ӵ��÷����������ӣ���ʹ�����ִ��䣬�Լ��ô����Ƿ�ʹ���� TLS ��

Quic

Quic ����Э�飬ʼ���ǰ�ȫ�ġ� ������ͻ�����������Ϊʹ�� Quic ,������ӽ�ʹ�� TLS ��

����:

// Always uses TLS.
await using var connection = new ClientConnection(
    "icerpc://hello.zeroc.com",
    multiplexedClientTransport: new QuicClientTransport());

ͬ�����߼�Ҳ�����ڷ�����:���������������Ϊʹ�� Quic ,��÷��������ܵ��κ����Ӷ���ʹ�� TLS ��

�� C# ��,��ҪΪ�κ�ʹ�� Quic �ķ�����ָ�� TLS ���ã��ر��� X.509 ֤�顣

����:

// SslServerAuthenticationOptions is required with QuicServerTransport.
await using var server = new Server(
    new Chatbot(),
    new SslServerAuthenticationOptions
    {
        ServerCertificate = new X509Certificate2("server.p12")
    },
    multiplexedServerTransport: new QuicServerTransport());

Tcp

Tcp �������ʹ��,Ҳ���Բ�ʹ�� TLS �������Ϊ Tcp �����ͻ�������ʱָ�� TLS ����,������ӽ�ʹ�� TLS �������ָ�� TLS ���ã����ӽ�����ʹ�� TLS ��

�� C# ��,�ÿͻ��� TLS ������ SslClientAuthenticationOptions �����ṩ������:

// The default multiplexed transport for icerpc is tcp (implemented by SlicClientTransport over TcpClientTransport).
// This connection does not use TLS since we don't pass a SslClientAuthenticationOptions parameter.
await using var plainTcpConnection = new ClientConnection("icerpc://hello.zeroc.com");

// We pass a non-null SslClientAuthenticationOptions so the connection uses TLS.
await using var secureTcpConnection = new ClientConnection(
    "icerpc://hello.zeroc.com",
    new SslClientAuthenticationOptions());

���� Tcp �ķ�������˵����һ���ġ�����ڴ����˷�����ʱ��ָ�� TLS ���ã���������������� TLS ���������ӡ� ����ڴ����˷�����ʱδָ�� TLS ���ã���������������������ܼ򵥵� tcp ���ӡ�

SSL (���� ice )

Ice ��������ַ����ָ��ssl���䣬���� ice://hello.zeroc.com?transport=ssl . ���� Ice �ض��� ssl ������ tcp ������ͬ������ʼ�հ�ȫ�����ⷽ�棬 ssl ���� quic ��

����:

// Uses the default client transport, TcpClientTransport.
await using var connection = new ClientConnection("ice://hello.zeroc.com?transport=ssl");

�൱��:

await using var connection = new ClientConnection(
    "ice://hello.zeroc.com?transport=tcp",
    new SslClientAuthenticationOptions());

ssl ��������������� Ice : Ice Ӧ�ó�������ȫ���ӵı�׼��ʽ��ʹ�þ��� ssl ��������ַ�Ĵ�����

IceRPC + Slice ������� ssl ��������ַ�ķ����ַʱ, ssl ���䲶�����Ϣ("��Ҫ TLS ")��ȷ���ͻ����ڵ��ô˷����ַʱ������ȫ���ӡ�

���� Ice , tcp ������ζ��"��ʹ�� TLS ". ���� IceRPC , tcp ������ζ����ͨ tcp �� tcp + tls ,����ȡ���� TLS ���á�

Icerpc Э��,�ͻ��˺ͷ���������������ͬ�� TLS ��������,���Ҵ��� transport=tcp �� icerpc ��������ַ,������ָ����������Ҫ TLS ��

coloc ����

���ڲ��Ե� coloc ���䣬��֧�� TLS �����ʹ�� coloc ָ�� TLS ����,���յ�����

// Does not work: can't get a TLS connection with a transport that doesn't support TLS.
await using var connection = new ClientConnection(
    "icerpc://colochost",
    new SslClientAuthenticationOptions()
    multiplexedClientTransport: new SlicClientTransport(colocClientTransport));

���߽���

  • һֱ������ͣ�� �����������ٶ�
  • ����IJ��ã������� ���� ��лл
  • ��������е�С��Ȥ����ɼ���Ŷ��һ��̽��������̽�� �������� ��
  • ���û������Ļ������ �� Ŷ
    IceRPCÖ®·þÎñÆ÷µØÖ·ÓëTLSµÄ°²È«ÐÔ->¿ìÀÖµÄRPC
С���Ƽ��Ķ�

�������������Ľ�Ϊ������Ϣ����������������ͬ���޹۵��֤ʵ��������

�����Ƶ����

����

ͬ������

����

ɨ��ά�����������ֻ��汾��

ɨ��ά����������΢�Ź��ںţ�

��վ�������������������ϴ��������ַ���İ�Ȩ���뷢�ʼ�[email protected]

��ICP��2022002427��-10 �湫��������43070202000427��© 2013~2025 haote.com ������