15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is only included in ssl_client_socket_nss.cc and
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ssl_server_socket_nss.cc to share common functions of NSS.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef NET_SOCKET_NSS_SSL_UTIL_H_
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define NET_SOCKET_NSS_SSL_UTIL_H_
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <prerror.h>
12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include <prio.h>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/net_export.h"
151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "net/base/net_log.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BoundNetLog;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Initalize NSS SSL library.
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NET_EXPORT void EnsureNSSSSLInit();
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Log a failed NSS funcion call.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void LogFailedNSSFunction(const BoundNetLog& net_log,
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const char* function,
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          const char* param);
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Map network error code to NSS error code.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PRErrorCode MapErrorToNSS(int result);
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// GetNSSModelSocket returns either NULL, or an NSS socket that can be passed
33a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// to |SSL_ImportFD| in order to inherit some default options.
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)PRFileDesc* GetNSSModelSocket();
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Map NSS error code to network error code.
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int MapNSSError(PRErrorCode err);
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci// Creates a NetLog callback for an SSL error.
401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciNetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error,
411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                                        int ssl_lib_error);
421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace net
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // NET_SOCKET_NSS_SSL_UTIL_H_
47